diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 74595bbf2..cf61085c1 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -620,7 +621,14 @@ namespace hex { #elif defined(OS_MACOS) return ::getBackingScaleFactor(); #elif defined(OS_LINUX) - return 1.0F; + if (std::string_view(::getenv("XDG_SESSION_TYPE")) == "x11") + return 1.0F; + else { + float xScale = 0, yScale = 0; + glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &xScale, &yScale); + + return std::midpoint(xScale, yScale); + } #elif defined(OS_WEB) return 1.0F; /* diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index cb76f9c17..54aa97f60 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -433,8 +433,16 @@ namespace hex::init { glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); #endif - #if defined(OS_LINUX) && defined(GLFW_WAYLAND_APP_ID) - glfwWindowHintString(GLFW_WAYLAND_APP_ID, "imhex"); + #if defined(OS_LINUX) + #if defined(GLFW_WAYLAND_APP_ID) + glfwWindowHintString(GLFW_WAYLAND_APP_ID, "imhex"); + #endif + + #if defined(GLFW_SCALE_FRAMEBUFFER) + glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE); + #endif + + glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); #endif // Make splash screen non-resizable, undecorated and transparent @@ -457,6 +465,8 @@ namespace hex::init { std::exit(EXIT_FAILURE); } + ImHexApi::System::impl::setMainWindowHandle(m_window); + // Force window to be fully opaque by default glfwSetWindowOpacity(m_window, 1.0F); @@ -469,7 +479,7 @@ namespace hex::init { if (meanScale <= 0.0F) meanScale = 1.0F; - meanScale /= hex::ImHexApi::System::getBackingScaleFactor(); + meanScale /= hex::ImHexApi::System::getBackingScaleFactor(); ImHexApi::System::impl::setGlobalScale(meanScale); ImHexApi::System::impl::setNativeScale(meanScale); diff --git a/main/gui/source/window/linux_window.cpp b/main/gui/source/window/linux_window.cpp index be7df68dd..efd40d1d9 100644 --- a/main/gui/source/window/linux_window.cpp +++ b/main/gui/source/window/linux_window.cpp @@ -114,9 +114,11 @@ namespace hex { void Window::configureGLFW() { #if defined(GLFW_SCALE_FRAMEBUFFER) - glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE); + glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE); #endif + glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_DECORATED, ImHexApi::System::isBorderlessWindowModeEnabled() ? GL_FALSE : GL_TRUE);