Repository navigation
steamcompmgr, wlserver: let XDG windows win focus over X11 windows - #2506
Open
jdonaldson wants to merge 1 commit into
Open
jdonaldson wants to merge 1 commit into
jdonaldson wants to merge 1 commit into
Conversation
Outside Steam mode every X11 window gets a synthetic appID (its window id) and is_focus_priority_greater ranks appID-bearing windows first. XDG windows only get an appID from their pid, which is 0 outside Steam, so a native Wayland game launched from an X11 launcher (e.g. Prism Launcher with --expose-wayland) is permanently out-focused by the launcher window that stays mapped behind it: the game runs, audio plays, but the launcher is what gets shown and gets input. Give XDG windows the same synthetic appID treatment (0x7FFF0000 + xdg id) so they are not dropped at the first comparison, and make a mixed X11/XDG comparison prefer the XDG window explicitly. The later tie-breaks in is_focus_priority_greater call xwayland() on both sides and would read the wrong variant of the window union for an XDG window. No behaviour change in Steam mode or between two X11 windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nested gamescope (
--expose-wayland, not Steam mode) with an X11 launcher that starts a native Wayland game: the game's xdg toplevel maps, audio plays, but gamescope keeps showing and focusing the launcher's X11 window.xprop -root GAMESCOPE_FOCUSED_WINDOWnames the launcher for as long as it stays mapped.Reproduced with Prism Launcher (Qt, forced to X11 with
QT_QPA_PLATFORM=xcb) launching Minecraft on GLFW's Wayland backend. Any X11 window that stays mapped behind an xdg toplevel does the same.Cause
Outside Steam mode
steamcompmgrgives every X11 window a syntheticappID(its window id, inadd_win), andis_focus_priority_greaterranks windows that have an appID first (win_has_game_id). XDG windows get their appID fromGetAppIdFromPid, which is 0 outside Steam, so they lose the very first comparison against any X11 window.Even past that check, the later tie-breaks call
xwayland()on both operands, which reads the wrong variant of the window union when one side is XDG.Change
wlserver.cpp: when!steamModeand the pid lookup gave 0, give the xdg window a synthetic appID too (0x7FFF0000 + xdg id), mirroring what X11 windows get.steamcompmgr.cpp: inis_focus_priority_greater, a mixed X11/XDG comparison prefers the XDG window, placed before the X11-only tie-breaks.No change in Steam mode, and none when comparing two X11 windows or two XDG windows.
Testing
The same change against 3.16.1 (the Ubuntu 25.04 package) has been in use for two days of actual play, together with the relative-mouse change in #2507:
--expose-wayland; Prism Launcher is an X11 (xcb) Qt client inside it and launches Minecraft on GLFW's Wayland backend.GAMESCOPE_FOCUSED_WINDOWnamed Prism's window. Workarounds were unmapping Prism's window by hand or Prism's "close after launch".This port is compile-tested on master (74a06ff), on its own and together with #2507. I don't have a master runtime on that machine yet, so a run-test on master would be welcome.
Disclosure: this PR was prepared with AI assistance (Anthropic's Claude Code) under my direction. The diagnosis, patches and the testing described above were done on my own setup.