Skip to content

topbar: fullscreen games keep fullscreen, also after Alt+Tab - #197

Open
pagliarinilucas wants to merge 1 commit into
Lemxy:mainfrom
pagliarinilucas:fix/fullscreen-alttab
Open

pagliarinilucas wants to merge 1 commit into
Lemxy:mainfrom
pagliarinilucas:fix/fullscreen-alttab

Conversation

@pagliarinilucas

@pagliarinilucas pagliarinilucas commented Nov 26, 2026 •

Copy link
Copy Markdown

Problem

I could not play Elden Ring in fullscreen with WinRust running. I used the floating dock and had Explorer replaced, and my monitor is 5120x1440.

  • On start: the screen went black, or the game would not stay fullscreen. It kept flickering in and out of fullscreen about once a second.
  • After Alt+Tab: even when the first start worked, switching to another window and back broke it again: black screen, the game minimizing itself, or the loop above. Once the first fixes below were in, it worked most of the time, but some returns still failed, and I had to Alt+Tab away and back two or three times.
  • Without the bar: with topbar.exe closed and everything else of WinRust still running, the game started and stayed fullscreen. So the bar was knocking the game out of fullscreen.

A WinEvent log (foreground, show/hide, location and z-order of the bar's and the game's windows) showed four separate causes.

Causes and fixes

All in plugins/topbar/src/main.rs (plus one call site in thumbs.rs).

  1. No foreground window during the mode switch. While a game switches the display mode, GetForegroundWindow() is null for a moment. fs_update took that as "fullscreen is over", the bar slid back in on top, and the game lost fullscreen and tried again.
    → fs_settled: the bar comes back only after fullscreen has been gone for 1.5 s without a break. The 250 ms poll keeps running while that wait is pending.
  2. The bar re-raised itself on every display change. place() (run on WM_DISPLAYCHANGE, which the game's mode switch causes) and bar_step called SetWindowPos(HWND_TOPMOST) without SWP_NOZORDER. That moved the bar above the game, which had just become topmost.
    → The bar keeps its z-order there. It is topmost from creation, and is raised again only when it comes back from hidden.
  3. A fullscreen game coming back with Alt+Tab is not seen as fullscreen. It gets the foreground while still minimized, and fullscreen_now returned false for any iconic window, so the bar stayed on top of it.
    → The window last seen fullscreen still counts while it is minimized. So does anything Windows reports as QUNS_RUNNING_D3D_FULL_SCREEN (SHQueryUserNotificationState).
  4. Switching to a minimized window restored it before activating it. The game got the foreground, lost it to the previous window, got it again, minimized itself and gave up on fullscreen. The log showed MINEND, MINSTART and a foreground flip back within 0.3 s.
    → A new bring(w) used by Alt+Tab, the bar buttons, the previews and the app menu. For a minimized window it calls SwitchToThisWindow(w, TRUE), which is what Windows' own Alt+Tab uses. Otherwise, or if that fails, it falls back to the old force_fg + SW_RESTORE.

Testing

  • cargo test -p topbar: 19 pass. cargo build --release is clean.
  • Tested on Windows 11 with a 5120×1440 monitor, Elden Ring started through Mod Organizer 2, the dock style, and Explorer replaced. Before: black screen or a fullscreen loop. After each fix, the WinEvent log showed the corresponding flip gone. With all four, the game stays fullscreen on start and after repeated Alt+Tab to other windows and back.
  • Not tested: other games, or the classic (non-dock) bar with Explorer running. The changes do not depend on the style, though.

Notes

🤖 Generated with Claude Code

A game switching into exclusive fullscreen (Elden Ring) dropped out of it again, in a loop, or stayed black after Alt+Tab:

- while the game switches the display mode there is no foreground window for a moment; the bar took that as "fullscreen
  is over", came back on top and knocked the game out. The bar now returns only after 1.5 s without fullscreen.
- place() and the slide animation re-inserted the bar at HWND_TOPMOST on every display change, i.e. above the game that
  had just become topmost. They keep the bar's z-order now (it is topmost from its creation); only a bar that comes back
  from hidden is raised.
- a fullscreen game brought back with Alt+Tab has the foreground while still minimized: the window that was last seen
  fullscreen (and any D3D app Windows reports as fullscreen, SHQueryUserNotificationState) counts as fullscreen then.
- switching to a minimized window (Alt+Tab, its button, a preview, the menu) restored it first and activated it after;
  the game got the foreground, lost it to the previous window and got it again, and gave up on fullscreen. Minimized
  windows now go through SwitchToThisWindow like Windows' own Alt+Tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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