Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

fix(gui): round thread card thumbnails under OpenGL

RoversX75c3d4ed3627
diff --git a/wezterm-gui/src/termwindow/live_overview.rs b/wezterm-gui/src/termwindow/live_overview.rs
index dbedeee4..2b425204 100644
--- a/wezterm-gui/src/termwindow/live_overview.rs
+++ b/wezterm-gui/src/termwindow/live_overview.rs
@@ -2513,7 +2513,7 @@ impl ContentView for LiveOverviewView {
chrome.preview,
chrome.clip,
chrome.fill,
- chrome.border,
+ Some(chrome.border),
ctx.px(PREVIEW_RADIUS),
)?;
}
diff --git a/wezterm-gui/src/termwindow/thread_window.rs b/wezterm-gui/src/termwindow/thread_window.rs
index 5e05d5b9..c1bffd5f 100644
--- a/wezterm-gui/src/termwindow/thread_window.rs
+++ b/wezterm-gui/src/termwindow/thread_window.rs
@@ -1019,17 +1019,36 @@ impl TermWindow {
zindex: crate::termwindow::DRAG_GHOST_ZINDEX,
}),
// OpenGL keeps it as quads, to play back where the
- // card is now.
- None => self.paint_terminal_previews(
- &mut layers,
- &[TerminalPreviewRequest {
- area: dest,
- clip: dest,
- prebuild: false,
- opacity,
- ..request
- }],
- )?,
+ // card is now. Nothing cuts their corners, so the
+ // card paints back over them.
+ None => {
+ self.paint_terminal_previews(
+ &mut layers,
+ &[TerminalPreviewRequest {
+ area: dest,
+ clip: dest,
+ prebuild: false,
+ opacity,
+ ..request
+ }],
+ )?;
+ let surface = self.tear_off_surface().mul_alpha(opacity);
+ let radius = self.ui_f32(TEAR_OFF_THUMBNAIL_RADIUS);
+ let gl_state = self
+ .render_state
+ .as_ref()
+ .context("tear-off card without a render state")?;
+ DrawContext::new(gl_state, self.dimensions, &self.render_metrics)
+ .draw_rounded_preview_chrome(
+ &mut layers,
+ 2,
+ dest,
+ dest,
+ surface,
+ None,
+ radius,
+ )?;
+ }
}
}
}
diff --git a/wezterm-gui/src/ui/draw.rs b/wezterm-gui/src/ui/draw.rs
index 114be7b0..84d33e67 100644
--- a/wezterm-gui/src/ui/draw.rs
+++ b/wezterm-gui/src/ui/draw.rs
@@ -298,9 +298,10 @@ impl<'a> DrawContext<'a> {
}
/// Cover the four wedges outside a rounded preview after the terminal has
- /// been painted, then redraw its thin outline. The complete chrome is
- /// emitted into a heap buffer and clipped as quads, so a corner crossing a
- /// scroll boundary remains rounded instead of disappearing all at once.
+ /// been painted, then redraw its thin outline if it has one. The complete
+ /// chrome is emitted into a heap buffer and clipped as quads, so a corner
+ /// crossing a scroll boundary remains rounded instead of disappearing all
+ /// at once.
pub(crate) fn draw_rounded_preview_chrome(
&self,
layers: &mut TripleLayerQuadAllocator<'_>,
@@ -308,7 +309,7 @@ impl<'a> DrawContext<'a> {
rect: RectF,
clip: RectF,
mask: LinearRgba,
- border: LinearRgba,
+ border: Option<LinearRgba>,
radius: f32,
) -> anyhow::Result<()> {
let radius = radius
@@ -352,54 +353,58 @@ impl<'a> DrawContext<'a> {
let mut clipped_layers = TripleLayerQuadAllocator::Heap(&mut heap);
for (x, y, mask_poly, outline_poly) in corners {
self.draw_corner(&mut clipped_layers, layer_num, x, y, mask_poly, size, mask)?;
- self.draw_corner(
- &mut clipped_layers,
- layer_num,
- x,
- y,
- outline_poly,
- size,
- border,
- )?;
+ if let Some(border) = border {
+ self.draw_corner(
+ &mut clipped_layers,
+ layer_num,
+ x,
+ y,
+ outline_poly,
+ size,
+ border,
+ )?;
+ }
}
- let stroke = self.px(1.0).max(1.0);
- let edges: [RectF; 4] = [
- euclid::rect(
- rect.min_x() + radius,
- rect.min_y(),
- rect.size.width - radius * 2.0,
- stroke,
- ),
- euclid::rect(
- rect.min_x() + radius,
- rect.max_y() - stroke,
- rect.size.width - radius * 2.0,
- stroke,
- ),
- euclid::rect(
- rect.min_x(),
- rect.min_y() + radius,
- stroke,
- rect.size.height - radius * 2.0,
- ),
- euclid::rect(
- rect.max_x() - stroke,
- rect.min_y() + radius,
- stroke,
- rect.size.height - radius * 2.0,
- ),
- ];
- for edge in edges {
- self.draw_rect(
- &mut clipped_layers,
- layer_num,
- edge.origin.x,
- edge.origin.y,
- edge.size.width,
- edge.size.height,
- border,
- )?;
+ if let Some(border) = border {
+ let stroke = self.px(1.0).max(1.0);
+ let edges: [RectF; 4] = [
+ euclid::rect(
+ rect.min_x() + radius,
+ rect.min_y(),
+ rect.size.width - radius * 2.0,
+ stroke,
+ ),
+ euclid::rect(
+ rect.min_x() + radius,
+ rect.max_y() - stroke,
+ rect.size.width - radius * 2.0,
+ stroke,
+ ),
+ euclid::rect(
+ rect.min_x(),
+ rect.min_y() + radius,
+ stroke,
+ rect.size.height - radius * 2.0,
+ ),
+ euclid::rect(
+ rect.max_x() - stroke,
+ rect.min_y() + radius,
+ stroke,
+ rect.size.height - radius * 2.0,
+ ),
+ ];
+ for edge in edges {
+ self.draw_rect(
+ &mut clipped_layers,
+ layer_num,
+ edge.origin.x,
+ edge.origin.y,
+ edge.size.width,
+ edge.size.height,
+ border,
+ )?;
+ }
}
}
let clip = QuadClipRect::from_top_left_pixels(