Skip to content

winit: repaint the whole window after restoring it from minimized - #13566

Closed
bigtree108-dmytro wants to merge 1 commit into
slint-ui:masterfrom
bigtree108-dmytro:repaint-after-restore-from-minimized
Closed

bigtree108-dmytro wants to merge 1 commit into
slint-ui:masterfrom
bigtree108-dmytro:repaint-after-restore-from-minimized

Conversation

@bigtree108-dmytro

@bigtree108-dmytro bigtree108-dmytro commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Windows and X11 drop what a minimized window had on screen. The buffer age a software surface reports counts it as still being there, so the first frame after the restore paints the dirty region alone and the rest of the window stays blank.

Reproduced on Windows 11 with the gallery example and no code of mine involved:

SLINT_BACKEND=winit-software cargo run --manifest-path examples/Cargo.toml -p gallery

Minimize the window, restore it, and it comes back black apart from the slider and the spinner. Those two are the items that kept animating while it was minimized, which is to say they are the dirty region. It happens on every cycle.

The renderer log shows what reaches the screen. While the window is minimized it keeps rendering and presenting, so the buffer stays marked as presented:

render size=1482x928 age=1 winit_inner=PhysicalSize { width: 0, height: 0 } minimized=Some(true)
damage [Rect { x: 245, y: 528, width: 514, height: 5 }, Rect { x: 1184, y: 533, width: 39, height: 38 }]

After the restore the age is still 1, so the partial renderer paints those same two rectangles into a window that holds nothing.

This is the same cause as #13500, so it takes the same shape as 24df530: mark the whole window dirty when the window stops being minimized. The marking from the mapping path moves into a helper the two share.

Measured over four minimize and restore cycles on a 1500x1000 window, comparing the restored window against the frame before the minimize, every third pixel:

pixels identical to the frame before the minimize
before 2.8 - 4.0 %
after 98.7 - 99.9 %

What remains after the fix is the spinner, which genuinely animates.

This is the trigger reported in #13537 by @iamdarkle. The grow across screens of different scale factors in the first post of that issue is a different path, it survives this change, and I am still on it.

  • I license this and all my future contributions to Slint under the MIT-0 license. They are my own work, and no third party (such as my employer) holds rights to them.

Windows and X11 discard what a minimized window had on screen. The buffer
age a software surface reports counts it as still being there, so the first
frame after the restore painted only the dirty region and the rest of the
window stayed blank. Only the items that had animated in the meantime
appeared.

Mark the whole window dirty when it stops being minimized, the same way as
after mapping it, and share that between the two.

This is the trigger reported in slint-ui#13537 by a second party. The grow across
screens of different scale factors in the first post of that issue is a
different path and still open.

ChangeLog: Software rendering with winit: a window restored from minimized is painted again instead of staying blank until something changes.
@github-actions

Copy link
Copy Markdown
Contributor

👋 Welcome, and thanks for your pull request! If you haven't yet, take a look at CONTRIBUTING.md.

Before we can merge it, tick the box at the end of the description to confirm that you agree to the licensing described in CONTRIBUTING.md#license. You only do this once. If you can't agree, tell us in a comment instead.

We're a small team and reviews can take a while. If you don't hear back, nudge us in our public chat.

@tronical
tronical requested a review from ogoffart September 22, 2026 14:26
@ogoffart ogoffart added candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran and removed candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran labels Sep 26, 2026
@ogoffart

Copy link
Copy Markdown
Member

Is this still needed now that we have updated #13568 ?

@bigtree108-dmytro

Copy link
Copy Markdown
Contributor Author

Thanks for asking, and sorry, I had X11 wrong. It isn't needed anywhere, so I'm closing it.

On Windows, #13568 covers the restore: Windows invalidates the whole client area when the window comes back, and the update rectangle carries that.

On X11 I've now measured it with the software renderer on Xvfb and openbox, with and without a compositor. After a restore or a map, winit reports Occluded(false) just before the redraw, and the occluded() hook in sw.rs already resets partial rendering, so master repaints the whole window: a static window came back 100 % intact and an animated one everything except the moving square, the same as with this PR. With that reset switched off, the window came back almost empty, and this PR didn't bring it back either, because its full frame is drawn when is_minimized flips, before the window is viewable again. I've corrected the X11 sentence in the #13568 description too.

For the wider picture: rust-windowing/winit#4719 proposes that winit report the invalidated area with each redraw, and rust-windowing/softbuffer#375 fixes softbuffer on Windows marking the whole window painted after copying only the damage.

@bigtree108-dmytro
bigtree108-dmytro deleted the repaint-after-restore-from-minimized branch November 18, 2026 09:52

This branch was successfully deployed

1 active deployment
pr-preview-13566 — a0e8da78 Deployed Sep 22, 2026 by github-actions[bot]
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.

2 participants