Disable X11 on Wayland unless explicitly activated.

This commit is contained in:
Patrick 2025-09-21 15:18:02 +02:00
parent 917309e99c
commit 180f2b70fa
2 changed files with 23 additions and 3 deletions

View File

@ -426,9 +426,9 @@ void Application::cleanup()
bool Application::initSDL() bool Application::initSDL()
{ {
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX #if MIJIN_TARGET_OS == MIJIN_OS_LINUX
// prefer x11 over wayland, as ImGui viewports don't work with wayland if (mConfig.flags.x11OnWayland) {
// 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");
SDL_SetHint(SDL_HINT_VIDEO_DRIVER, "x11,wayland"); }
#endif #endif
if (!SDL_Init(SDL_INIT_VIDEO)) if (!SDL_Init(SDL_INIT_VIDEO))
{ {

View File

@ -51,6 +51,21 @@ struct FontConfig
FontFlags flags; FontFlags flags;
}; };
struct ApplicationFlags : mijin::BitFlags<ApplicationFlags>
{
/**
* (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 class Application
{ {
private: private:
@ -65,6 +80,7 @@ private:
bool mRunning = true; bool mRunning = true;
ImGuiWindowFlags mMainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS; ImGuiWindowFlags mMainWindowFlags = DEFAULT_MAIN_WINDOW_FLAGS;
std::unordered_map<ImGuiStyleVar, std::variant<float, ImVec2>> mMainWindowStyles; std::unordered_map<ImGuiStyleVar, std::variant<float, ImVec2>> mMainWindowStyles;
const ApplicationConfig mConfig;
using GLbitfield = std::uint32_t; using GLbitfield = std::uint32_t;
using GLint = std::int32_t; using GLint = std::int32_t;
@ -91,8 +107,12 @@ private:
glTexImage2D_fn_t glTexImage2D; glTexImage2D_fn_t glTexImage2D;
glDeleteTextures_fn_t glDeleteTextures; glDeleteTextures_fn_t glDeleteTextures;
public: public:
explicit Application(ApplicationConfig config = {}) noexcept : mConfig(config) {}
virtual ~Application() = default; virtual ~Application() = default;
[[nodiscard]]
const ApplicationConfig& getConfig() const noexcept { return mConfig; }
[[nodiscard]] [[nodiscard]]
mijin::StackedFileSystemAdapter& getFS() { return mFS; } mijin::StackedFileSystemAdapter& getFS() { return mFS; }