fix(linux): a Steam launch on the Deck's desktop asks for an X11 window, so Steam follows the focus #2803
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2803
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:fix/deck-x11-under-steam"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Started by Steam in Desktop Mode on a Steam Deck, the game got Steam's Desktop layout for the controller instead of
the game's, so a face button opened the in-game menu and the left trigger sent Escape. Nothing was wrong with the pad or
the mapping: the game ran as a native Wayland window, and Steam is an X11 client that does not follow the focus of a
Wayland window. It therefore never saw the game as the foreground application and kept the desktop layout bound, at
logs/controller.txt:Queueing activation for controller: 15 app: 413080(Steam's desktop app), while the game's ownapp id was only warmed.
This asks for an X11 window first when Steam started the process on a Steam Deck's desktop session, and keeps Wayland
first otherwise, for its mailbox present. With an X11 window Steam activates the game's own app id within a second and
the pad behaves as it does in Game Mode.
The choice is one pure function,
hos_sdl_video_orderinhost/hos_video_order.h, asked byhost/posix/display_sdl.cwhere it used to hard-code"wayland,x11". It takes three inputs: the process was started bySteam (
SteamGameId,SteamAppIdorSTEAM_COMPAT_CLIENT_INSTALL_PATH), gamescope is not the compositor, and themachine is a Steam Deck (
JupiterorGalileofrom/sys/devices/virtual/dmi/id/product_name). Under gamescope(Game Mode) it returns nothing and SDL keeps its own order, so Game Mode is untouched.
Why the Deck only. The fault is Steam's, not the Deck's: any native Wayland game started from Steam on a Wayland
desktop gets the desktop layout. Preferring X11 everywhere is also the riskier change, because the renderer picks
mailbox when the Vulkan surface has one and stays FIFO otherwise (
gpu/vk/vk_main.cpp, V-Sync Auto), so a desktop whoseX11 surface lacks mailbox can lose vblank for the whole session. That cost is measured only on the hardware in Testing,
so the rule stops there; the other desktops keep Wayland, and widening it needs the matched frame-time comparison the
review asked for. A session with no XWayland at all still falls back to Wayland inside SDL, keeping Steam's desktop
layout, which is Steam's own bug in that configuration.
A variable Steam sets counts only when it holds a value: one exported and left empty is a wrapper's placeholder, not a
launch, and does not switch a Deck's desktop to X11.
The hint is only the order SDL picks from: it is skipped entirely when
SDL_VIDEODRIVERorSDL_VIDEO_DRIVERis alreadyset (a player or a launcher can do that), and SDL chooses the first driver that initializes, so the X11 entry is a
preference that Wayland still answers when X11 cannot open a display.
To see the bug on
main: start the game from a Steam shortcut in Desktop Mode on a Deck, then press a face button. Itopens the in-game menu instead of acting, and Steam's
logs/controller.txtshows the controller activated for app413080.Testing
Tested: Steam Deck LCD (VANGOGH, RADV, SteamOS 7.2.7-valve2-neptune), Desktop Mode with Steam running, started from a
Steam shortcut. Before: a face button opened the Longshot menu, the left trigger sent Escape,
xdotoolsaw no X11window, and Steam's log showed the desktop app
413080bound. After: the window is X11, Steam's log showsQueueing activation for controller: 15 app: -1211248510(the game's own shortcut id), and the pad drives the menusand the game normally. The same build in Game Mode is unchanged and correct, and with Steam closed the game still starts
a Wayland window and the pad works as before.
The rule itself is covered game-free:
tests/test_video_order.pycompileshos_sdl_video_orderand checks all threeinputs for the Deck's two models, a machine that must keep Wayland, and the gamescope case.
Frame pacing on the Deck, X11 against Wayland, matched: the same build, the same settings (V-Sync Auto), the same
window size (swapchain 1152x718), the title scene, present-to-present times from
RX_VK_FRAME_TRACE, both logvk: swapchain 1152x718, 4 images, mailbox (V-Sync Auto). Frames 600 to 9600 of each run:Whole runs, startup hitches included: 7.06 ms against 6.95 ms mean, 1% low 30.03 against 30.16, worst 311 against
318 ms. The X11 swapchain on this Deck gets mailbox from RADV, so the concern that leaving Wayland would cost the Deck
its mailbox does not hold here.
No XWayland: with
DISPLAYunset so no X11 display can be opened, the same launch (Steam's variables set, the Deck)starts anyway: Wayland window, 6121 frames presented, mailbox, no X11 window at all, exit code 0.
On the Deck LCD the rule was exercised both ways: with Steam's launch variables set the game opens an X11 window
(
xdotoolfindsLongshot, its pid the game's); with the same variables exported but empty there is no X11 window atall, so it runs on Wayland.
Suite on this machine:
tests/run_all.py --strict(Linux,CXX=g++) reports the same 211 failures onmainand onthis branch, every one of them a test that needs a tool this machine does not have (
clang,clang++); this branchadds none.
mise run testitself cannot run here: its pinnedruffandpre-commitneeduv>= 0.12.10 and thismachine has 0.11.26. CI has both.
Still to test: an OLED Deck (DMI
Galileo, the same name list) by hand: a contributor with that hardware.Measurements
Verdict: the bug reproduces on
mainand is gone here on the hardware measured: Steam's own log moves from itsdesktop app to the game's app id, and the game-free check pins the rule and its limits.
Setup: Steam Deck LCD, RADV, SteamOS 7.2.7-valve2; Desktop Mode; Steam's
logs/controller.txt,xdotoolfor thewindow kind, and
tests/test_video_order.py, which compileshos_sdl_video_orderand checks the cases.01d6878b0e374933tests/test_video_order.pyhos_video_order.hdoes not existapp: 413080(Steam's desktop app)app: -1211248510(the game's own id)Risks
On a Steam Deck's desktop session under Steam the window is presented through X11 instead of Wayland, and the reason
Wayland was preferred is its mailbox present, which X11 surfaces do not all have. Frame pacing on that path is not
measured: the change was verified for input, and it is now confined to the one platform where at least that much is
known. Every other machine keeps the old order, so their presentation is untouched. Reverting is one line and Game Mode
is not affected. Nothing else changes: no options keys, no saves, nothing on screen.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Steam Deck LCD (VANGOGH, RADV), SteamOS 7.2.7-valve2-neptune, Desktop Mode with Steam running, started from a Steam shortcut. Before: a face button opened the Longshot menu and L2 sent Escape, and Steam's log bound the controller to app 413080 (its desktop app). After: the window is X11, Steam's log shows the controller activated for the game's own app id within a second, and the pad drives the menus and the game normally. The same build in Game Mode is unchanged and correct.
@review — ready. The whole change is one rule,
hos_sdl_video_orderinhost/hos_video_order.h, asked wheredisplay_sdl.cused to hard-code the order; Game Mode takes no new path. Frame pacing on the X11 path in Desktop Mode is not measured, and the description says so. Related: #2802, found on the same build.Recommendation: Request changes. The Deck test shows that the controller fix works there. The presentation cost on affected desktop systems also needs measurement before merge.
Steam desktop launches prefer an X11 window so Steam can apply the game's controller layout; other launches retain their existing order. This fixes the reported input problem on the tested Deck, at the cost of changing the presentation path for Steam desktop launches.
Blocking (1): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 24s.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/posix/display_sdl.c:354: The X11 presentation path's frame pacing and behavior on other affected Linux GPU drivers have not been measured. (more on the line) Do: Compare main and this head on affected NVIDIA and AMD Linux desktops, using the same scene and settings for multiple interleaved runs; report frame times, 1% lows and present behavior. (@fixdoes its part first: Preserve Wayland where Steam can follow its focus, if such a detectable configuration is available.)host/posix/display_sdl.c:354: The stated fallback when XWayland is unavailable has not been tested. (more on the line) Do: Run a Steam launch without XWayland and verify that SDL initializes Wayland and the game starts, recording the SDL version and result.@fixcan do L1 and L3.Questions (1) (not confirmed from the code; they don't hold the recommendation)
tests/test_video_order.py:35: Is there a current launch configuration where the selected order does not reach SDL?Checks: Still running: 8 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: on the tested Steam Deck, Steam changed from binding its desktop app 413080 to the game's shortcut ID, and the reported face-button and trigger behavior was corrected. The presentation cost has not been measured.
Other systems: Linux Steam desktop launches on other GPUs and compositors also take the X11 path; its presentation and frame pacing are unmeasured. Game Mode and non-Steam launches retain the previous selection, and Windows does not use this display implementation. Fallback on a desktop without XWayland remains untested.
Switches: No switches added, changed or removed. Existing SDL video-driver environment overrides retain precedence.
Reviewed:
f2f1637b5fagainst01d6878b3f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff and commit, all changed files, and the display startup fixture and caller. Skimmed references to SDL driver selection and Steam environment variables. No review checklist file was present; no translations or generated files changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. The author reports a successful Deck game test; CI still has checks running and one head-only failure already recorded separately.
Overlaps and merge order: Related PR #2802 is mentioned, but its contents and overlap were unavailable in the supplied context.
Automated code review by BeanBot (gpt-6.1-terra), asked for by omgitsgela. Nothing was run; a maintainer decides.
@ -347,0 +351,4 @@const int steam_launch = getenv("SteamGameId") || getenv("SteamAppId") || getenv("STEAM_COMPAT_CLIENT_INSTALL_PATH");const char* order = hos_sdl_video_order(steam_launch, gamescope);if (!getenv("SDL_VIDEODRIVER") && !getenv("SDL_VIDEO_DRIVER") && order)hos_sdl_hint(hos_sdl_load() == 3 ? "SDL_VIDEO_DRIVER" : "SDL_VIDEODRIVER", order);L1 (should fix): The X11 presentation path's frame pacing and behavior on other affected Linux GPU drivers have not been measured.
When: A Steam desktop launch on a driver whose X11 surface lacks mailbox presentation now uses X11 instead of Wayland; its present mode and frame pacing can differ throughout play.
Do: Compare main and this head on affected NVIDIA and AMD Linux desktops, using the same scene and settings for multiple interleaved runs; report frame times, 1% lows and present behavior.
L2 (should fix): The stated fallback when XWayland is unavailable has not been tested.
When: A Steam-launched game in a Wayland desktop without an available X11 server now asks SDL to initialize X11 first; the claimed fallback to a working Wayland window has not been observed.
Do: Run a Steam launch without XWayland and verify that SDL initializes Wayland and the game starts, recording the SDL version and result.
CI note:
Third-party parts and guide screenshotsfails here because it fails onmaintoo.scripts/check_guide_screenshots.py --review-sourcesonorigin/main(01d6878b) saysREVIEW REQUIRED: settings-graphics.png: game/oot_cheat_items.h changed since reviewed revision 3c74597e, from #2785; neither branch touchesgame/. The rest of the checks are running.Recommendation: Request changes. The Deck controller fix is reproduced and useful. Narrow the default or verify that switching the Vulkan surface preserves desktop presentation on the affected hardware.
Does it help? Yes for the reported input failure. The author’s matched Steam Deck LCD / SteamOS 7.2.7-valve2-neptune report showed Steam leave desktop layout app 413080 and bind the shortcut app -1211248510 in about a second. The face button and left trigger returned to game behavior. Game Mode and the non-Steam launch were also checked.
Blocking — host/posix/display_sdl.c:354. The new hint prefers X11 for every detected Steam desktop launch. The current renderer chooses mailbox if available and otherwise stays FIFO under Linux V-Sync Auto (gpu/vk/vk_main.cpp:1265–1293), so losing mailbox can change default frame pacing and latency. NVIDIA X11 with V-Sync Off can still pick immediate and reproduce cross-monitor tearing when the surface advertises it, the reason the Wayland preference was introduced in
b54bec179. Either scope the default to an evidenced configuration or compare main and this head on Steam Deck RADV and affected NVIDIA/AMD Wayland desktops. Keep the route and settings fixed, report selected present mode and frame-time distribution/1% lows, and check the second monitor with V-Sync Off on NVIDIA.Fallback coverage. The driver list does fall through when X11 cannot create a device, including when SDL2 cannot open DISPLAY. Once SDL chooses an X11 device, it does not try Wayland on later VideoInit, window, or Vulkan surface failure. Distinguish these cases in the description and test the missing-XWayland case. https://github.com/libsdl-org/SDL/blob/release-2.32.10/src/video/SDL_video.c#L482-L530 · https://github.com/libsdl-org/SDL/blob/release-2.32.10/src/video/x11/SDL_x11video.c#L141-L161
Checks: Exact PR run 57579 had six passes and five red jobs. All three touched/new fixtures passed. The guide error identifies game/oot_cheat_items.h changed by main #2785, outside this diff. Rust log names unchanged rustfmt and synthetic layout code. Website reports /settings/ game branding from unchanged files. The exact-base push status is pending, so do not assume the remaining failed suites passed on the base. https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/57579
Reviewed:
f2f1637b5fagainst01d6878b3f. No new switches. Explicit SDL driver choice and the gamescope branch still take precedence. Related #2802 changes IMU transport and tests only, with no shared changed files or required merge order.CI comparison: all 31 failing game-free test names match the union of the two shards on disjoint sibling #2802 at the same base, although the shard assignments differ. Guide, Rust and Website failure details also match. The exact base's push run 57375 had not run those checks. https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/57577
@ -347,0 +351,4 @@const int steam_launch = getenv("SteamGameId") || getenv("SteamAppId") || getenv("STEAM_COMPAT_CLIENT_INSTALL_PATH");const char* order = hos_sdl_video_order(steam_launch, gamescope);if (!getenv("SDL_VIDEODRIVER") && !getenv("SDL_VIDEO_DRIVER") && order)hos_sdl_hint(hos_sdl_load() == 3 ? "SDL_VIDEO_DRIVER" : "SDL_VIDEODRIVER", order);[P2] Narrow this default or verify presentation on affected Steam Wayland desktops. Preferring X11 changes the Vulkan surface, so V-Sync Auto can move from mailbox to FIFO and alter latency or pacing. Include present-mode selection and a matched frame-time comparison on configurations covered by the new default.
f2f1637b5f5d9ed3d099fix(linux): a Steam launch on a Wayland desktop asks for an X11 window, so Steam follows the focusto fix(linux): a Steam launch on the Deck's desktop asks for an X11 window, so Steam follows the focusScoped, as the review asked (
5d9ed3d0).JupiterorGalileofrom/sys/devices/virtual/dmi/id/product_name). Every other machine keepswayland,x11, exactly as onmain, so no other desktop's presentation path changes and there is no unmeasured cost left outside the Deck. Widening the rule beyond it is the follow-up, and it needs the matched frame-time comparison (present mode, 1% lows) on the drivers in question rather than an argument.main's Wayland path on the Deck itself, which is in Still to test, along with the no-XWayland session.SDL_VIDEODRIVERorSDL_VIDEO_DRIVERis already set, and under gamescope the function returns nothing. Otherwise SDL tries the drivers in the given order and takes the first that initializes, so the X11 entry is a preference that Wayland still answers when X11 cannot open a display.game/oot_cheat_items.hfrom #2785, outside this diff, as you said.@review
Recommendation: Approve. The code is ready: only testing is left. The reported Deck controller failure is fixed in the author's test, and the new default is limited to Decks. The affected X11 path still needs a frame-pacing comparison and the no-XWayland fallback needs a run. Recommend approval; not approved on the forge.
Steam launches on a Deck desktop prefer X11 so Steam can bind the game's controller layout; other desktops keep the previous Wayland preference. This confines the presentation tradeoff to the affected hardware, at the cost of an unmeasured change to its presentation path.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/posix/display_sdl.c:354: The Deck's X11 presentation path has not been compared with main's Wayland path. When: A Steam launch in Deck Desktop Mode now uses X11 first, which can select a different Vulkan present mode and change frame pacing. Do: Compare main and this head on the Deck in the same scene and settings with interleaved runs, reporting present mode and frame-time distribution and 1% lows. (@fixdoes its part first: Preserve Wayland where Steam can follow its focus, if such a detectable configuration is available.)host/posix/display_sdl.c:354: The stated fallback when XWayland is unavailable has not been tested. When: A Steam-launched game in a Wayland desktop without an available X11 server now asks SDL to initialize X11 first; the claimed fallback to a working Wayland window has not been observed. Do: Run a Steam launch without XWayland and verify that SDL initializes Wayland and the game starts, recording the SDL version and result.@fixcan do L1.Since the last review (on
f2f1637b5f)Still open: L1 (The Deck's X11 presentation path has not been compared with main's Wayland path.); L2 (The stated fallback when XWayland is unavailable has not been tested.); L3 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…)Checks: Failing on this head, which is behind its base, where they pass:
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request),CI / Website build and checks (pull_request),CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request).@rebase(or@fix) brings it up to date and runs them again; not held against it.More: does it help, other systems, switches, what was read
Does it help: Yes for the reported input bug: the author's Steam Deck LCD test moved Steam's binding from desktop app 413080 to the game's shortcut app, and the controller worked in game. Frame pacing against main was not measured.
Other systems: Game Mode retains SDL's own order, and non-Deck machines retain Wayland first. Explicit SDL driver choices still take precedence. Deck X11 presentation and the missing-XWayland fallback remain unmeasured.
Switches: None added, changed or removed. Existing SDL driver environment overrides remain authoritative.
Reviewed:
5d9ed3d099against01d6878b3f: Read the diff, commit, repository rules, PR template, standards, video-order header and test, and display initialization and its surrounding code. Skimmed the two adapted display fixtures and renderer present-mode selection; other renderer code was not read in full. Tooling's adjacent rules checkout and docs/review-checklist.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports in-game Deck testing and game-free checks; the missing frame-pacing and fallback runs remain.
Overlaps and merge order: Related PR #2802 changes IMU transport and tests; the prior review reports no shared changed files or required merge order.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
5d9ed3d0990e37493314Deck-only rule tested on a Steam Deck LCD (DMI
Jupiter, vendorValve), with this head (0e374933) built on the Deck itself (longshot-builder, compile only, shaders at first start):xdotoolfindsLongshotandgetwindowpidis the game's own pid.hos_env_setnow treats it as unset.What that does and does not say: the rule reaches SDL and changes the window type on the Deck, and it does nothing without the launch markers. It does not measure frame pacing of the X11 path against main's Wayland path, which is still in Still to test along with a session that has no XWayland.
On hardware the fallback also ran in this build: see #2802's comment for the gyro side.
Ready for another look: the head is
0e374933, rebased onto the newmain(f14a5664) and mergeable. The default is now the Deck only, an emptySteamGameIdno longer counts, and both cases were exercised on the Deck as described above.Frame pacing and the no-XWayland case are now measured on the Deck, same build, same settings (V-Sync Auto, swapchain 1152x718), same title scene, present-to-present from
RX_VK_FRAME_TRACE; both runs logvk: swapchain 1152x718, 4 images, mailbox (V-Sync Auto), so the X11 swapchain keeps mailbox on RADV:Whole runs including startup: 7.06 against 6.95 ms mean, 1% low 30.03 against 30.16, worst 311 against 318 ms.
No XWayland: with
DISPLAYunset so no X11 display can open, the same Steam-marked launch still starts (Wayland window, 6121 frames, mailbox, no X11 window, exit 0).That leaves the OLED Deck, which I cannot run. Description updated with all of it.
Short answer: no, not from inside the game, and the reason is on Steam's side.
In Desktop Mode the Steam client is itself an X11 client. On the Deck right now:
Xwayland :0 -rootlessis running, and Steam's own windows (nameSteam) belong tosteamwebhelperand are X11 windows. From what can be observed, its controller binding follows the focused X11 window: with a native Wayland window Steam kept the desktop app (413080) bound even though it was the only thing on screen, and with an X11 window it binds the game's own id within about a second.A Wayland-native window cannot become that window. Wayland gives a client no way to announce itself to another client, and Steam exposes no call or variable through which a game hands over its app id; even a Wayland-native Steam would need the compositor's foreign-toplevel to tell it what is focused, and would still have to map that to an app itself. So the window type is the only lever the game has, which is why the change is that and nothing more.
It costs nothing extra on Plasma, because XWayland is already running for Steam's own client; and where there is no X11 display at all the code falls through to Wayland and the game starts anyway (measured on the Deck with
DISPLAYunset: Wayland window, 6121 frames, mailbox, exit 0).Game Mode is untouched: gamescope owns the session, Steam knows what it launched, and the hint returns nothing there.
So yes, it would be more natural for Steam to follow a Wayland window, but that is Steam's change to make. If it ever tracks Wayland toplevels, this rule collapses back to a one-line default and can be deleted. If you would rather keep Wayland and live with the controller bug until then, that is a legitimate product call, just not something the game can fix from its side.