From 4a33dcc1bce8515d508751a06e2c79759af71b47 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 20 Sep 2020 14:33:42 +0200 Subject: [PATCH] Support DPI scaling on Linux. --- profiler/src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 33b1ef16..66fd2468 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -275,10 +275,17 @@ int main( int argc, char** argv ) typedef UINT(*GDFS)(void); GDFS getDpiForSystem = nullptr; HMODULE dll = GetModuleHandleW(L"user32.dll"); - if (dll != INVALID_HANDLE_VALUE) - getDpiForSystem = (GDFS)GetProcAddress(dll, "GetDpiForSystem"); - if (getDpiForSystem) - dpiScale = getDpiForSystem() / 96.f; + if( dll != INVALID_HANDLE_VALUE ) getDpiForSystem = (GDFS)GetProcAddress(dll, "GetDpiForSystem"); + if( getDpiForSystem ) dpiScale = getDpiForSystem() / 96.f; +#elif defined __linux__ + auto monitor = glfwGetWindowMonitor( window ); + if( !monitor ) monitor = glfwGetPrimaryMonitor(); + if( monitor ) + { + float x, y; + glfwGetMonitorContentScale( monitor, &x, &y ); + dpiScale = x; + } #endif // Setup ImGui binding