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.

feat(gui): paint the ground of pages in the terminal's place

RoversX688470526624
diff --git a/wezterm-gui/src/termwindow/content_view.rs b/wezterm-gui/src/termwindow/content_view.rs
index b7624958..489c443b 100644
--- a/wezterm-gui/src/termwindow/content_view.rs
+++ b/wezterm-gui/src/termwindow/content_view.rs
@@ -638,6 +638,13 @@ pub(crate) trait ContentView {
Ok(())
}
+ /// Whether the window paints this view's ground, as see-through as the
+ /// terminal's, and cuts the view to its area. Only for a view in the
+ /// terminal's place: a full-window view is left to itself.
+ fn host_paints_ground(&self) -> bool {
+ true
+ }
+
/// Select a native chrome font role rather than inventing view-local font
/// sizes. Overview uses the same sidebar, pane-header and settings roles
/// as the rest of ThinkTerm.
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 4f3bada8..b6ac4956 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -9985,6 +9985,14 @@ impl TermWindow {
}
}
+ /// The ground of a page in the terminal's place: as see-through as the
+ /// terminal's, so that going between them changes nothing behind.
+ pub(crate) fn content_view_ground(&self) -> LinearRgba {
+ self.terminal_shade
+ .unwrap_or(self.chrome().window_bg)
+ .mul_alpha(self.terminal_ground_opacity(self.config.window_background_opacity))
+ }
+
fn dark_interface(&self) -> bool {
matches!(
self.chrome_appearance,
diff --git a/wezterm-gui/src/termwindow/onboarding.rs b/wezterm-gui/src/termwindow/onboarding.rs
index e5ce6764..7b9d61ec 100644
--- a/wezterm-gui/src/termwindow/onboarding.rs
+++ b/wezterm-gui/src/termwindow/onboarding.rs
@@ -2195,6 +2195,10 @@ fn language_preference_for(settings: &ThinkTermNativeSettings) -> &'static str {
}
impl ContentView for OnboardingView {
+ fn host_paints_ground(&self) -> bool {
+ false
+ }
+
fn title(&self) -> String {
crate::i18n::tr("onboarding-window-title")
}
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 70c5ab11..4e93ed0e 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -2,7 +2,9 @@ use crate::quad::{
translated_clipped_vertices, HeapQuadAllocator, HeapQuadMark, QuadClipRect, QuadTrait,
TripleLayerQuadAllocator, Vertex,
};
-use crate::termwindow::content_view::{ContentViewTypography, TerminalPreviewRequest};
+use crate::termwindow::content_view::{
+ ContentViewPresentation, ContentViewTypography, TerminalPreviewRequest,
+};
use crate::termwindow::render::{LineToEleShapeCacheKey, RenderScreenLineParams};
use crate::termwindow::{PaintOutcome, RenderFrame, TermWindowNotif, UIItem, UIItemType};
use crate::ui::DrawContext;
@@ -2557,6 +2559,8 @@ impl crate::TermWindow {
// Occupy the terminal content area between the workspace and right
// sidebars, below the top tab bar and above a bottom tab bar.
let area = self.content_view_area();
+ let page_ground = self.content_view_ground();
+ let page_clip = self.clip_of(area);
let surface = euclid::rect(
0.0,
0.0,
@@ -2605,17 +2609,48 @@ impl crate::TermWindow {
view.set_defer_preview_captures(defer_preview_captures);
view.set_host_preview_aspect(host_preview_aspect);
view.paint_surface_background(&ctx, layers, surface, palette)?;
- view.paint(
- &ctx,
- layers,
- area,
- palette,
- &ui_font,
- &title_font,
- &section_font,
- &caption_font,
- cursor_on,
- )?;
+ if view.presentation() == ContentViewPresentation::ContentArea
+ && view.host_paints_ground()
+ {
+ // Cut to the area: there is no solid ground above it to
+ // hide a page that has scrolled past its top.
+ ctx.draw_rect(
+ layers,
+ 0,
+ area.origin.x,
+ area.origin.y,
+ area.size.width,
+ area.size.height,
+ page_ground,
+ )?;
+ let mut page_palette = palette;
+ page_palette.window_bg = page_ground;
+ let mut page = HeapQuadAllocator::default();
+ view.paint(
+ &ctx,
+ &mut TripleLayerQuadAllocator::Heap(&mut page),
+ area,
+ page_palette,
+ &ui_font,
+ &title_font,
+ &section_font,
+ &caption_font,
+ cursor_on,
+ )?;
+ page.apply_to_clipped(layers, page_clip, 1.0)?;
+ } else {
+ view.paint(
+ &ctx,
+ layers,
+ area,
+ palette,
+ &ui_font,
+ &title_font,
+ &section_font,
+ &caption_font,
+ cursor_on,
+ )?;
+ }
(view.next_frame_time(), view.terminal_previews())
} else {
(None, Vec::new())
diff --git a/wezterm-gui/src/termwindow/ssh_hosts_view.rs b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
index a1c1ac59..a672028e 100644
--- a/wezterm-gui/src/termwindow/ssh_hosts_view.rs
+++ b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
@@ -6124,6 +6124,10 @@ fn open_thread_response(project_id: String) -> ContentViewResponse {
}
impl ContentView for SshHostsView {
+ fn host_paints_ground(&self) -> bool {
+ false
+ }
+
fn title(&self) -> String {
crate::i18n::tr("ssh-hosts-title")
}