diff options
Diffstat (limited to 'crates/wayland/src/winit')
| -rw-r--r-- | crates/wayland/src/winit/capture.rs | 27 | ||||
| -rw-r--r-- | crates/wayland/src/winit/connect.rs | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/crates/wayland/src/winit/capture.rs b/crates/wayland/src/winit/capture.rs index 095b56b..3813559 100644 --- a/crates/wayland/src/winit/capture.rs +++ b/crates/wayland/src/winit/capture.rs @@ -96,6 +96,7 @@ impl WaylandPlatform { // as both on-screen render loops do it. let monitor_bounds: Vec<srdwm_core::Rect> = self.wm.borrow().monitors().iter().map(|m| m.full_geometry).collect(); let mut occluders: Vec<srdwm_core::Rect> = Vec::new(); + let focused = self.wm.borrow().focused_id(); for id in self.wm.borrow().visible_windows_front_to_back().map(|w| w.id).collect::<Vec<_>>() { let Some(w) = self.wm.borrow().window(id).cloned() else { continue }; if let Some(deco) = self.state.decorations.get(&id) { @@ -158,6 +159,32 @@ impl WaylandPlatform { } } } + // Border strips, as plain solid fills. + // + // The on-screen loop draws the top and bottom strips from + // cached bitmaps so their corners round into the titlebar's + // curve, and only the sides as fills. This pass approximates + // all four with fills: corner rounding is not reproduced, so a + // capture is not pixel-exact at the four corners. Everything + // that matters for checking a border - whether one is drawn at + // all, where, how thick, and in what colour - is faithful. + // + // Without this a screenshot could not answer "is there a border + // here", which is exactly the question a border bug asks. That + // gap was documented and then walked into twice: a maximize + // border fix was checked against a capture that never draws + // borders, and the control silently passed for the wrong + // reason both times. + if w.border_width > 0 && !w.maximized { + let color = crate::state::effective_border_color(w.border_color, focused == Some(id), self.wm.borrow().theme.border_inactive_dim); + let frame = self.state.effective_frame(id, w.geometry); + for (index, strip) in crate::decoration::border_strips(frame, w.border_width).into_iter().enumerate() { + for fragment in crate::elements::visible_border_fragments(strip, &occluders) { + let buf = crate::elements::border_fragment_buffer(&mut self.state.capture_border_buffers, index); + custom_elements.push(crate::elements::OverlayElement::Solid(crate::elements::border_side_render_element(buf, fragment, color, (0, 0)))); + } + } + } occluders.push(w.geometry); } custom_elements.extend(crate::elements::output_layer_elements(renderer, &self.output, |layer| matches!(layer, Layer::Background | Layer::Bottom))); diff --git a/crates/wayland/src/winit/connect.rs b/crates/wayland/src/winit/connect.rs index 1648826..aa59d9d 100644 --- a/crates/wayland/src/winit/connect.rs +++ b/crates/wayland/src/winit/connect.rs @@ -180,6 +180,7 @@ impl WaylandPlatform { rounded_content_buffers: HashMap::new(), border_side_buffers: HashMap::new(), snap_preview_buffers: Vec::new(), + capture_border_buffers: Vec::new(), color_filter_buffers: HashMap::new(), last_synced_size: HashMap::new(), provisional_size: HashSet::new(), |