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.

Add content_view_area and use in mouse/paint

RoversXdd4c8aa94f89
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index c4dfdcaa..1473daf4 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -2618,6 +2618,32 @@ impl TermWindow {
self.active_content_view_index().is_some()
}
+ pub(crate) fn content_view_area(&self) -> RectF {
+ let (padding_left, padding_top) = self.padding_left_top();
+ let border = self.get_os_border();
+ let top_tab_h = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
+ self.tab_bar_pixel_height().unwrap_or(0.0)
+ } else {
+ 0.0
+ };
+ let bottom_tab_h = if self.show_tab_bar && self.config.tab_bar_at_bottom {
+ self.tab_bar_pixel_height().unwrap_or(0.0)
+ } else {
+ 0.0
+ };
+ let left = padding_left + border.left.get() as f32;
+ let top = border.top.get() as f32 + top_tab_h + padding_top;
+ let right = self
+ .dimensions
+ .pixel_width
+ .saturating_sub(border.right.get() as usize)
+ .saturating_sub(self.right_sidebar_width()) as f32;
+ let bottom =
+ (self.dimensions.pixel_height as f32 - border.bottom.get() as f32 - bottom_tab_h)
+ .max(top);
+ euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0))
+ }
+
fn content_view_visible_in_active_space(&self, tab: &ContentViewTab) -> bool {
match tab.space_id.as_deref() {
Some(space_id) => space_id == self.active_space_id,
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 00a81e13..a716c90d 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -982,11 +982,14 @@ impl super::TermWindow {
context.set_cursor(Some(MouseCursor::Arrow));
let px = event.coords.x as f32;
let py = event.coords.y as f32;
- let resp = self
- .active_content_view_mut()
- .map(|v| v.on_mouse(px, py, event.kind));
- if let Some(resp) = resp {
- self.handle_content_response(resp);
+ let area = self.content_view_area();
+ if px >= area.min_x() && px < area.max_x() && py >= area.min_y() && py < area.max_y() {
+ let resp = self
+ .active_content_view_mut()
+ .map(|v| v.on_mouse(px, py, event.kind));
+ if let Some(resp) = resp {
+ self.handle_content_response(resp);
+ }
}
} else if matches!(
self.current_mouse_capture,
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index a540aee0..9832429e 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -207,28 +207,9 @@ impl crate::TermWindow {
let dimensions = self.dimensions;
let palette = UiPalette::for_appearance(crate::native_settings::effective_appearance());
- // Occupy exactly the terminal content area: right of the (possibly
- // collapsed) sidebar and below the tab bar. padding_left_top().0 already
- // includes the effective sidebar width.
- let (padding_left, padding_top) = self.padding_left_top();
- let border = self.get_os_border();
- let top_tab_h = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- let bottom_tab_h = if self.show_tab_bar && self.config.tab_bar_at_bottom {
- self.tab_bar_pixel_height().unwrap_or(0.0)
- } else {
- 0.0
- };
- let left = padding_left + border.left.get() as f32;
- let top = border.top.get() as f32 + top_tab_h + padding_top;
- let width = (dimensions.pixel_width as f32 - left - border.right.get() as f32).max(0.0);
- let height =
- (dimensions.pixel_height as f32 - top - border.bottom.get() as f32 - bottom_tab_h)
- .max(0.0);
- let area = euclid::rect(left, top, width, height);
+ // 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 active_content_view_idx = self.active_content_view_index();
// Cursor blink: only animate when the view wants it (focused input).