srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/winit/render.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-08-09 00:57:00 +0200
committersrdusr <[email protected]>2025-08-09 00:57:00 +0200
commit61d01bb79c6882c950f45a1176ba1f30fbbd4824 (patch)
treeeb2a24c7f301f74f987f954b62d768c9cb789fef /crates/wayland/src/winit/render.rs
parent9e811d2f2f1037ba4ec08ab0e05b350e6cf69e66 (diff)
downloadsrdwm-61d01bb79c6882c950f45a1176ba1f30fbbd4824.tar.gz
srdwm-61d01bb79c6882c950f45a1176ba1f30fbbd4824.zip
Fix interactive-resize border/shadow lag without the OOB risk that sank the first attempt
effective_frame_of now returns the live drag target while a window is being interactively resized (same change as the reverted first attempt), but two things make it safe this time instead of reintroducing the out-of-bounds texture sample that reversion was for: - Every src crop rect built from a window's frame width in udev/render.rs and winit/render.rs (titlebar, top border strip, bottom border strip) is now clamped against DecorationSignature's own recorded width/ border_width - the bitmap's actual last-built size - before reaching MemoryRenderBufferRenderElement::from_buffer, which does not itself validate src against the real texture size. This is a structural floor independent of timing, not a repeat of the previous unsafe approach. - handle_pointer_position now calls redraw_decoration_buffer once per resize motion event (throttled to 60Hz via a new CompState::resize_redraw_at), closing the lag at its source instead of only catching up on the next real client commit. This also fixes the shadow bitmap's identical commit-vs-live-position gap for free, since redraw_decoration_buffer rebuilds all three bitmaps together. Updates the TODO.md entry for this bug with the full before/after.
Diffstat (limited to 'crates/wayland/src/winit/render.rs')
-rw-r--r--crates/wayland/src/winit/render.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/wayland/src/winit/render.rs b/crates/wayland/src/winit/render.rs
index 6f5f600..345d40c 100644
--- a/crates/wayland/src/winit/render.rs
+++ b/crates/wayland/src/winit/render.rs
@@ -238,7 +238,13 @@ impl WaylandPlatform {
// only once *fully* covered) wasn't enough: a titlebar
// only partially covered, the common case for cascaded
// windows, still bled through the covered part.
- let titlebar_rect = srdwm_core::Rect::new(frame.x, frame.y, frame.width, srdwm_core::TITLEBAR_HEIGHT);
+ // Live-resize safety clamp - see the matching clamp in
+ // `udev/render.rs`'s own titlebar push for the full
+ // reasoning: `frame.width` can be the live drag target
+ // (via `effective_frame_of`), ahead of whatever size this
+ // buffer was actually last built at.
+ let titlebar_w = self.state.decoration_signatures.get(&id).map(|s| s.width).unwrap_or(frame.width).min(frame.width);
+ let titlebar_rect = srdwm_core::Rect::new(frame.x, frame.y, titlebar_w, srdwm_core::TITLEBAR_HEIGHT);
for fragment in crate::elements::visible_border_fragments(titlebar_rect, &occluders) {
let pos = (fragment.x as f64, fragment.y as f64);
let src = Rectangle::new(
@@ -285,7 +291,10 @@ impl WaylandPlatform {
// away instead of landing on real content.
let (row0, rows, shift) = decoration::border_top_visible_rows(border_curve_is_safe, w.border_width, w.corner_radius);
let pos = (strips[0].x as f64, (strips[0].y + shift as i32) as f64);
- let src = Some(Rectangle::new(Point::from((0.0, row0 as f64)), Size::from((strips[0].width as f64, rows as f64))));
+ // Same live-resize safety clamp as the titlebar push
+ // above and `udev/render.rs`'s matching top strip.
+ let crop_w = self.state.decoration_signatures.get(&id).map(|s| s.width + 2 * s.border_width).unwrap_or(strips[0].width).min(strips[0].width);
+ let src = Some(Rectangle::new(Point::from((0.0, row0 as f64)), Size::from((crop_w as f64, rows as f64))));
match MemoryRenderBufferRenderElement::from_buffer(renderer, pos, buffer, None, src, None, Kind::Unspecified) {
Ok(elem) => custom_elements.push(crate::rounded_corners::WinitElement::Base(crate::elements::OverlayElement::Memory(elem))),
Err(e) => log::warn!("failed to import top border buffer for window {id}: {e}"),
@@ -301,7 +310,10 @@ impl WaylandPlatform {
// own doc comment.
let (row0, rows, shift) = decoration::border_bottom_visible_rows(border_curve_is_safe, w.border_width, w.corner_radius);
let pos = (strips[1].x as f64, (strips[1].y - shift as i32) as f64);
- let src = Some(Rectangle::new(Point::from((0.0, row0 as f64)), Size::from((strips[1].width as f64, rows as f64))));
+ // Same live-resize safety clamp as the top strip
+ // above and `udev/render.rs`'s matching bottom strip.
+ let crop_w = self.state.decoration_signatures.get(&id).map(|s| s.width + 2 * s.border_width).unwrap_or(strips[1].width).min(strips[1].width);
+ let src = Some(Rectangle::new(Point::from((0.0, row0 as f64)), Size::from((crop_w as f64, rows as f64))));
match MemoryRenderBufferRenderElement::from_buffer(renderer, pos, buffer, None, src, None, Kind::Unspecified) {
Ok(elem) => custom_elements.push(crate::rounded_corners::WinitElement::Base(crate::elements::OverlayElement::Memory(elem))),
Err(e) => log::warn!("failed to import bottom border buffer for window {id}: {e}"),