Skip to content

steamcompmgr, wlserver: let XDG windows win focus over X11 windows - #2506

Open
jdonaldson wants to merge 1 commit into
ValveSoftware:masterfrom
jdonaldson:xdg-focus-priority
Open

jdonaldson wants to merge 1 commit into
ValveSoftware:masterfrom
jdonaldson:xdg-focus-priority

Conversation

@jdonaldson

@jdonaldson jdonaldson commented Oct 18, 2026 •

Copy link
Copy Markdown

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_WINDOW names 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 steamcompmgr gives every X11 window a synthetic appID (its window id, in add_win), and is_focus_priority_greater ranks windows that have an appID first (win_has_game_id). XDG windows get their appID from GetAppIdFromPid, 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 !steamMode and the pid lookup gave 0, give the xdg window a synthetic appID too (0x7FFF0000 + xdg id), mirroring what X11 windows get.
  • steamcompmgr.cpp: in is_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:

  • Setup: a Proxmox VM with an RTX 4090 (NVIDIA 550), running Wolf streaming to Moonlight on a Mac. gamescope runs nested under Wolf's compositor with --expose-wayland; Prism Launcher is an X11 (xcb) Qt client inside it and launches Minecraft on GLFW's Wayland backend.
  • Games: Minecraft 1.21.1 Fabric with ~64 mods (Distant Horizons, Iris + Complementary shaders, several camera mods) and Minecraft 26.1.2 with the Satisfaction Guaranteed pack (62 mods), across several sessions each.
  • Before the change the launch spinner cleared, music played, and the stream kept showing the launcher; GAMESCOPE_FOCUSED_WINDOW named Prism's window. Workarounds were unmapping Prism's window by hand or Prism's "close after launch".
  • After it the game is on top at every launch with Prism still mapped behind it, Prism is back when the game quits, and relaunching from Prism inside the same session works. Prism's own menus and dialogs behave as before.

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant