From acc1d371eada001743aee51c8d716a37e01320f9 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Tue, 28 Jan 2025 02:09:31 +0200 Subject: [PATCH] _sigh --- .../Engine/Platform/SDL/SDLPlatform.Linux.cpp | 20 ------------------- Source/Engine/Platform/SDL/SDLPlatform.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp b/Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp index a0763d1c3..717962a81 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp @@ -1299,25 +1299,6 @@ int X11ErrorHandler(X11::Display* display, X11::XErrorEvent* event) bool SDLPlatform::InitInternal() { - //if (LinuxPlatform::Init()) - // return true; - -#if false - if (!CommandLine::Options.Headless && strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) - { - WaylandDisplay = (wl_display*)SDL_GetPointerProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, nullptr); - - wl_registry* registry = wl_display_get_registry(WaylandDisplay); - wl_registry_add_listener(registry, &WaylandRegistryListener, nullptr); - - wl_display_roundtrip(WaylandDisplay); - - dataDevice = wl_data_device_manager_get_data_device(WaylandDataDeviceManager, WaylandSeat); - wl_data_device_add_listener(dataDevice, &WaylandDataDeviceListener, nullptr); - - wl_display_roundtrip(WaylandDisplay); - } -#else bool waylandRequested = (!CommandLine::Options.X11 || CommandLine::Options.Wayland) && StringAnsi(SDL_GetHint(SDL_HINT_VIDEO_DRIVER)) == "wayland"; if (!CommandLine::Options.Headless && waylandRequested) { @@ -1335,7 +1316,6 @@ bool SDLPlatform::InitInternal() } } } -#endif return false; } diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp index e3efb55f5..790d6498a 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -41,7 +41,12 @@ bool SDLPlatform::Init() else if (CommandLine::Options.Wayland) SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); else - SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_DEFAULT); + { + // Override the X11 preference when running in Wayland session + String waylandDisplayEnv; + if (!GetEnvironmentVariable(String("WAYLAND_DISPLAY"), waylandDisplayEnv)) + SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); + } #endif #if PLATFORM_LINUX