srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/protocols/compositor.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2026-07-23 22:56:00 +0200
committersrdusr <[email protected]>2026-07-23 22:56:00 +0200
commit8ed79c21a53e10c29ea35b9a605250ea18f191cf (patch)
tree22fbfc5a9348c7449a0b831e8066020a5faa68a4 /crates/wayland/src/protocols/compositor.rs
parentc3a34348b39c9518ad2e5bb28569fb9d78ce5dc1 (diff)
downloadsrdwm-8ed79c21a53e10c29ea35b9a605250ea18f191cf.tar.gz
srdwm-8ed79c21a53e10c29ea35b9a605250ea18f191cf.zip
Do not draw a window before its client has painted anything
Reported as "before a window spawns, the border corners look funny". A toplevel is placed, sized and decorated the moment its role is created, which is well before the client draws. srdwm was rendering it from that moment, so what appeared first was an empty frame: border, titlebar and shadow standing around bare desktop, at the guessed 800x600 placeholder size, with nothing inside. When the real buffer arrived the frame snapped to the real size. Measured in a nested session, capturing a cold terminal's spawn with grim: four consecutive captured frames spanning 540ms showed a complete red border with zero client content inside it, at 642px outer height, which then settled at 610 - a jump of exactly one TITLEBAR_HEIGHT. After this change the same capture has no such frame at all: every frame that shows a border shows content in it, and the height does not change afterward. Two parts: - Nothing is drawn for a window that has never committed a buffer. All five paths that draw a frame agree on this - both udev render loops (Pixman and GPU), the winit render loop, and both screencopy paths, so a screenshot cannot show a frame the screen does not. - The open-slide starts at the first commit that carries a buffer rather than at role creation. A cold terminal took ~800ms to paint, long enough for the whole tween to finish against the empty frame, so the window simply appeared, already at rest, with no animation at all. It now animates where it can actually be seen. The answer latches once true (windows_shown_once), so a window that has legitimately shown something is never hidden again by this however its buffer state changes. A window that cannot be resolved to a surface counts as drawable, deliberately: this hides a window only on positive evidence that it has never drawn, so nothing whose surface plumbing works differently - an XWayland window - can be hidden by a lookup that did not apply to it. Same shape, and the same reason, as sync_layer_visibility's own has_buffer branch, which layer surfaces have had all along. 533 tests pass, clippy clean.
Diffstat (limited to 'crates/wayland/src/protocols/compositor.rs')
-rw-r--r--crates/wayland/src/protocols/compositor.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/wayland/src/protocols/compositor.rs b/crates/wayland/src/protocols/compositor.rs
index e2868e4..7be5d7e 100644
--- a/crates/wayland/src/protocols/compositor.rs
+++ b/crates/wayland/src/protocols/compositor.rs
@@ -89,6 +89,24 @@ impl CompositorHandler for CompState {
// own first real size a chance to adopt it from what `on_commit`
// just recomputed, rather than keep rendering/configuring
// against the guessed placeholder for one more round-trip.
+ // The first commit that actually carries a buffer is when this
+ // window becomes visible, so it is also when the open-slide
+ // should start - see `windows_shown_once`. Registered here
+ // rather than in `new_managed_window` because a role is created
+ // well before a client paints (measured at ~800ms for a cold
+ // terminal), which is long enough for the whole tween to finish
+ // against an empty frame and for the window to simply appear,
+ // already at rest, with no animation at all.
+ if !self.windows_shown_once.contains(&id) && self.window_has_content(id) {
+ self.windows_shown_once.insert(id);
+ let mut wm = self.wm.borrow_mut();
+ if wm.animations_enabled {
+ if let Some(win) = wm.window_mut(id) {
+ let g = win.geometry;
+ win.anim_from = Some(srdwm_core::Rect { y: g.y + crate::state::OPEN_SLIDE_OFFSET, ..g });
+ }
+ }
+ }
self.adopt_provisional_size(id);
// See `content_epoch`'s doc comment: this is the only per-commit
// signal the udev backend's rounded-corner mask cache has to