diff --git a/scripts/run.sh b/scripts/run.sh index 1a27f85..8c3bc6c 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -11,13 +11,9 @@ ENGINE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export DOTNET_ROOT="${DOTNET_ROOT:-$HOME/.dotnet}" export PATH="$DOTNET_ROOT:$PATH" -# Prefer Wayland if available, fall back to X11 -if [ -n "$WAYLAND_DISPLAY" ]; then - export SDL_VIDEODRIVER="${SDL_VIDEODRIVER:-wayland}" -else - export DISPLAY="${DISPLAY:-:0}" - export SDL_VIDEODRIVER="${SDL_VIDEODRIVER:-x11}" -fi +# Auto-detect Wayland. SDL3 bundled with ppy.SDL3-CS supports both Wayland and X11; +# let it choose based on available display servers. Do NOT force DISPLAY here. +unset SDL_VIDEODRIVER 2>/dev/null cd "$ENGINE_DIR" exec dotnet run --project "$ENGINE_DIR/src/CortexEngine.App/CortexEngine.App.csproj" -c Debug -- "$@" diff --git a/src/Engine.Core/Sdl3Window.cs b/src/Engine.Core/Sdl3Window.cs index 024aede..d8e9e9a 100644 --- a/src/Engine.Core/Sdl3Window.cs +++ b/src/Engine.Core/Sdl3Window.cs @@ -46,6 +46,11 @@ public sealed unsafe class Sdl3Window : IWindow SDL3.SDL_ShowWindow(_window); SDL3.SDL_RaiseWindow(_window); + + // On Wayland, the compositor needs an event round-trip before mapping + // the window. Pump events to flush the show request without blocking. + SDL_Event flushEvt; + while (SDL3.SDL_PollEvent(&flushEvt)) { } } public void PumpEvents()