From 180f2b70fa1b1b922ea45ebf0092a20e87f48a99 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sun, 21 Sep 2025 15:18:02 +0200 Subject: [PATCH] Disable X11 on Wayland unless explicitly activated. --- private/raid/application.cpp | 6 +++--- public/raid/raid.hpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/private/raid/application.cpp b/private/raid/application.cpp index cdc27e5..78594da 100644 --- a/private/raid/application.cpp +++ b/private/raid/application.cpp @@ -426,9 +426,9 @@ void Application::cleanup() bool Application::initSDL() { #if MIJIN_TARGET_OS == MIJIN_OS_LINUX - // prefer x11 over wayland, as ImGui viewports don't work with wayland - // TODO: this still doesn't work all the time, maybe there will be an update to ImGui in the future? - SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "x11,wayland"); + if (mConfig.flags.x11OnWayland) { + SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "x11,wayland"); + } #endif if (!SDL_Init(SDL_INIT_VIDEO)) { diff --git a/public/raid/raid.hpp b/public/raid/raid.hpp index 5a1f54b..188f0ec 100644 --- a/public/raid/raid.hpp +++ b/public/raid/raid.hpp @@ -51,6 +51,21 @@ struct FontConfig FontFlags flags; }; +struct ApplicationFlags : mijin::BitFlags +{ + /** + * (Linux only) prefer X11 even when on Wayland. Required for multi-viewport support, but currently really buggy. + * \see https://github.com/ocornut/imgui/issues/8609 + * \see https://github.com/ocornut/imgui/issues/8587 + */ + bool x11OnWayland : 1 = false; +}; + +struct ApplicationConfig +{ + ApplicationFlags flags = {}; +}; + class Application { private: @@ -65,6 +80,7 @@ private: bool mRunning = true; ImGuiWindowFlags mMainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS; std::unordered_map> mMainWindowStyles; + const ApplicationConfig mConfig; using GLbitfield = std::uint32_t; using GLint = std::int32_t; @@ -91,8 +107,12 @@ private: glTexImage2D_fn_t glTexImage2D; glDeleteTextures_fn_t glDeleteTextures; public: + explicit Application(ApplicationConfig config = {}) noexcept : mConfig(config) {} virtual ~Application() = default; + [[nodiscard]] + const ApplicationConfig& getConfig() const noexcept { return mConfig; } + [[nodiscard]] mijin::StackedFileSystemAdapter& getFS() { return mFS; }