1
0
mirror of synced 2025-01-10 21:41:53 +01:00

impr: Properly scale window on wayland

This commit is contained in:
WerWolv 2025-01-03 15:09:06 +01:00
parent 525ab8d945
commit dcd80fe6ad
3 changed files with 25 additions and 5 deletions

View File

@ -11,6 +11,7 @@
#include <wolv/utils/string.hpp>
#include <utility>
#include <numeric>
#include <imgui.h>
#include <imgui_internal.h>
@ -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;
/*

View File

@ -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);

View File

@ -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);