diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 4e2205333..282d9cf7d 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -291,6 +291,8 @@ namespace hex { bool isProcessElevated(); + std::optional getEnvironmentVariable(const std::string &env); + namespace scope_guard { #define SCOPE_GUARD ::hex::scope_guard::ScopeGuardOnExit() + [&]() diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 22dc8b0d8..c2f3dc8c5 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -451,4 +451,13 @@ namespace hex { #endif } + std::optional getEnvironmentVariable(const std::string &env) { + auto value = std::getenv(env.c_str()); + + if (value == nullptr) + return std::nullopt; + else + return value; + } + } \ No newline at end of file diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 2e8a1ea48..93a80eea4 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -41,6 +41,7 @@ #include "init/tasks.hpp" #include +#include #include @@ -650,9 +651,12 @@ namespace hex { style.WindowRounding = 0.0F; io.ConfigFlags |= ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_NavEnableKeyboard; -#if !defined(OS_LINUX) - io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; -#endif + + { + auto sessionType = hex::getEnvironmentVariable("XDG_SESSION_TYPE"); + if (!sessionType || !hex::containsIgnoreCase(*sessionType, "wayland")) + io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; + } for (auto &entry : fonts->ConfigData) io.Fonts->ConfigData.push_back(entry);