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): scope recording masks to panes and show them in live overview

RoversXb9cc3dcf3155
diff --git a/docs/thinkterm/recording-overlay.md b/docs/thinkterm/recording-overlay.md
index 96a3b912..62219e1a 100644
--- a/docs/thinkterm/recording-overlay.md
+++ b/docs/thinkterm/recording-overlay.md
@@ -13,9 +13,15 @@ application captures the mouse, hold the mouse-reporting bypass modifier
- Reopen **Edit Recording Masks…** to adjust them, or choose **Clear Recording Masks**
from the terminal context menu to remove them all.
-The canvas is transparent outside the masks. Masks stay at fixed window positions;
-they do not follow text when the terminal scrolls. They belong to the current window
-and are discarded when it closes. Up to 64 masks can be added.
+Each terminal pane owns its own transparent masking layer, with up to 64 masks.
+Switching terminals or splitting a tab does not transfer masks to other panes.
+Masks follow their pane between windows in the same GUI process and scale with it,
+including its Live Overview thumbnail and opening/closing transition. Clearing masks
+only affects the selected pane. The floating toolbar remains a window-level editor.
+
+Masks stay at fixed relative positions within the pane; they do not follow text
+when the terminal scrolls. They are local visual state, discarded when the pane
+closes or the GUI process exits. They are not synchronized to other GUI clients.
This is a visual cover for screen recording. Terminal contents, clipboard copies,
logs, and remote clients retain the original text. Check the recording preview
diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rs
index 42c45170..0afaf4fc 100644
--- a/wezterm-gui/src/frontend.rs
+++ b/wezterm-gui/src/frontend.rs
@@ -317,7 +317,9 @@ impl GuiFrontEnd {
MuxNotification::FrontendLeaseChanged(_) => {}
MuxNotification::FrontendAccessChanged(_) => {}
MuxNotification::TabAddedToWindow { .. } => {}
- MuxNotification::PaneRemoved(_) => {}
+ MuxNotification::PaneRemoved(pane_id) => {
+ crate::termwindow::ui::recording_overlay::forget_pane(pane_id);
+ }
MuxNotification::WindowInvalidated(_) => {}
MuxNotification::PaneOutput(_) => {}
MuxNotification::AgentStatusChanged(_) => {}
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 1be0a550..54fdbec6 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -8154,7 +8154,7 @@ impl super::TermWindow {
crate::i18n::tr("menu-clear-recording-overlay"),
ContextMenuIcon::Refresh,
crate::termwindow::ContextMenuApplicationAction::ClearRecordingOverlay,
- !self.recording_overlay.is_empty(),
+ !self.active_pane_recording_masks_empty(),
),
ContextMenuItem::Separator,
split_item(
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 028c8f4f..c044eac7 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -173,6 +173,7 @@ pub(crate) struct CachedPreviewQuads {
/// The card rectangle these quads were laid out in.
area: RectF,
heap: HeapQuadAllocator,
+ mask_regions: Vec<(mux::pane::PaneId, RectF, crate::termwindow::ui::recording_overlay::PaneRecordingLayer)>,
/// The card's picture as a texture (WebGpu only). Rendered from `heap`
/// when content changes; composited as a single quad on every other
/// frame, which is what makes an unchanged card nearly free.
@@ -224,6 +225,7 @@ pub(crate) struct PreviewRebuildPartial {
#[allow(dead_code)]
snapshot: Arc<crate::termwindow::content_view::TerminalPreviewSnapshot>,
heap: HeapQuadAllocator,
+ mask_regions: Vec<(mux::pane::PaneId, RectF, crate::termwindow::ui::recording_overlay::PaneRecordingLayer)>,
/// Resume point: the next pane and the next line within it.
pane_idx: usize,
line_idx: usize,
@@ -1947,6 +1949,24 @@ impl crate::TermWindow {
if self.paint_terminal_preview(layers, preview, &mut budget)? {
rebuilt += 1;
}
+ // Masks stay live above cached textures, including during sliced rebuilds.
+ // Use the geometry of the picture actually being replayed, not a newer snapshot.
+ let cache = self.preview_quad_cache.borrow();
+ if let Some(cached) = cache.get(&preview.tab_id) {
+ let sx = preview.area.width() / cached.area.width().max(1.0);
+ let sy = preview.area.height() / cached.area.height().max(1.0);
+ let alpha = self.preview_content_alpha(preview) * preview.opacity.clamp(0.0, 1.0);
+ for (_, rect, masks) in &cached.mask_regions {
+ let frame = euclid::rect(
+ preview.area.min_x() + (rect.min_x() - cached.area.min_x()) * sx,
+ preview.area.min_y() + (rect.min_y() - cached.area.min_y()) * sy,
+ rect.width() * sx, rect.height() * sy,
+ );
+ if let Some(clip) = preview.clip.intersection(&preview.area) {
+ self.paint_recording_mask_layer(masks, frame, clip, layers, alpha)?;
+ }
+ }
+ }
}
// What a frame spent on thumbnails, and how much of that was a card
// whose quads could not be replayed. Without the split, a slow frame
@@ -2134,6 +2154,7 @@ impl crate::TermWindow {
key,
snapshot: Arc::clone(&preview.snapshot),
heap,
+ mask_regions: Vec::new(),
pane_idx: 0,
line_idx: 0,
}
@@ -2148,6 +2169,7 @@ impl crate::TermWindow {
preview,
&mut partial.pane_idx,
&mut partial.line_idx,
+ &mut partial.mask_regions,
deadline,
)?;
crate::perf::log_duration("preview_rebuild_card", card_started);
@@ -2179,7 +2201,7 @@ impl crate::TermWindow {
self.update_next_frame_time(Some(Instant::now()));
return Ok(true);
}
- let PreviewRebuildPartial { heap, .. } = partial;
+ let PreviewRebuildPartial { heap, mask_regions, .. } = partial;
let prior_texture = self
.preview_quad_cache
.borrow_mut()
@@ -2241,6 +2263,7 @@ impl crate::TermWindow {
snapshot: Arc::clone(&preview.snapshot),
area: preview.area,
heap,
+ mask_regions,
texture,
},
);
@@ -2399,6 +2422,7 @@ impl crate::TermWindow {
preview: &TerminalPreviewRequest,
resume_pane: &mut usize,
resume_line: &mut usize,
+ mask_regions: &mut Vec<(mux::pane::PaneId, RectF, crate::termwindow::ui::recording_overlay::PaneRecordingLayer)>,
deadline: Instant,
) -> anyhow::Result<bool> {
let snapshot = &preview.snapshot;
@@ -2557,6 +2581,9 @@ impl crate::TermWindow {
let pane_width = pane.width as f32 * cell_width;
let pane_height = pane.height as f32 * cell_height;
let pane_rect = euclid::rect(pane_x, pane_y, pane_width, pane_height);
+ if mask_regions.last().is_none_or(|(id, _, _)| *id != pane.pane_id) {
+ mask_regions.push((pane.pane_id, pane_rect, crate::termwindow::ui::recording_overlay::pane_layer(pane.pane_id)));
+ }
let Some(pane_bounds) = pane_rect.intersection(&preview.area) else {
continue;
};
@@ -4021,6 +4048,9 @@ impl crate::TermWindow {
}
}
self.paint_pane(&pos, &mut layers).context("paint_pane")?;
+ if let Ok(frame) = self.pane_frame_rect(&pos) {
+ self.paint_pane_recording_masks(pos.pane.pane_id(), frame, &mut layers)?;
+ }
}
if let Some(pane) = self.get_active_pane_or_overlay() {
@@ -4373,8 +4403,7 @@ impl crate::TermWindow {
// Last, so the tag sits above every chrome surface it might overhang.
self.paint_hover_tooltip().context("paint_hover_tooltip")?;
- // Window-space masks are composited last and never baked into a
- // terminal/overview capture, so content transitions cannot move them.
+ // Only the floating editor is window-local; masks are painted with their panes.
self.paint_recording_overlay()
.context("paint_recording_overlay")?;
diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rs
index 6c2599df..c6e01e10 100644
--- a/wezterm-gui/src/termwindow/ui/context_menu.rs
+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs
@@ -228,7 +228,7 @@ impl crate::TermWindow {
self.start_recording_overlay_edit();
}
crate::termwindow::ContextMenuApplicationAction::ClearRecordingOverlay => {
- self.recording_overlay.clear();
+ self.clear_active_pane_recording_masks();
if let Some(window) = &self.window {
window.invalidate();
}
diff --git a/wezterm-gui/src/termwindow/ui/recording_overlay.rs b/wezterm-gui/src/termwindow/ui/recording_overlay.rs
index b50c6c2b..0d289472 100644
--- a/wezterm-gui/src/termwindow/ui/recording_overlay.rs
+++ b/wezterm-gui/src/termwindow/ui/recording_overlay.rs
@@ -1,7 +1,11 @@
-//! A window-local recording canvas. Only its opaque rectangles are painted;
+//! Pane-owned recording masks, shared by terminal and preview rendering.
//! normal input passes through unless the user explicitly enters edit mode.
+use crate::quad::TripleLayerQuadAllocator;
use crate::ui::{DrawContext, SvgIcon};
use crate::utilsprites::RenderMetrics;
+use mux::pane::PaneId;
+use std::collections::HashMap;
+use std::sync::{Arc, LazyLock, Mutex};
use window::color::LinearRgba;
use window::{KeyCode, KeyEvent, MouseCursor, MouseEvent, MouseEventKind, MousePress, WindowOps};
@@ -19,7 +23,61 @@ struct Rect {
h: f32,
}
+// GUI-local state follows a pane between windows; no terminal or mux data changes.
+// Rectangles are normalized to the pane frame, so previews reuse the same geometry.
+#[derive(Clone, Default)]
+pub(crate) struct PaneRecordingLayer(Arc<Mutex<Vec<Rect>>>);
+
+impl PaneRecordingLayer {
+ fn is_empty(&self) -> bool {
+ self.0.lock().unwrap().is_empty()
+ }
+}
+
+static PANE_MASKS: LazyLock<Mutex<HashMap<PaneId, PaneRecordingLayer>>> =
+ LazyLock::new(|| Mutex::new(HashMap::new()));
+
+fn pane_masks(pane_id: PaneId) -> Option<PaneRecordingLayer> {
+ PANE_MASKS.lock().unwrap().get(&pane_id).cloned()
+}
+
+pub(crate) fn forget_pane(pane_id: PaneId) {
+ PANE_MASKS.lock().unwrap().remove(&pane_id);
+}
+
+pub(crate) fn pane_layer(pane_id: PaneId) -> PaneRecordingLayer {
+ PANE_MASKS
+ .lock()
+ .unwrap()
+ .entry(pane_id)
+ .or_default()
+ .clone()
+}
+
+fn save_pane_masks(pane_id: PaneId, masks: Vec<Rect>) {
+ *pane_layer(pane_id).0.lock().unwrap() = masks;
+}
+
impl Rect {
+ fn normalized(self, size: (f32, f32)) -> Self {
+ Self {
+ x: self.x / size.0.max(1.0),
+ y: self.y / size.1.max(1.0),
+ w: self.w / size.0.max(1.0),
+ h: self.h / size.1.max(1.0),
+ }
+ .fitted((1.0, 1.0))
+ }
+
+ fn in_frame(self, frame: window::RectF) -> window::RectF {
+ euclid::rect(
+ frame.min_x() + self.x * frame.width(),
+ frame.min_y() + self.y * frame.height(),
+ self.w * frame.width(),
+ self.h * frame.height(),
+ )
+ }
+
fn between(a: (f32, f32), b: (f32, f32)) -> Self {
Self {
x: a.0.min(b.0),
@@ -81,6 +139,8 @@ struct Drag {
pub(crate) struct RecordingOverlay {
// UI coordinates, independent of terminal font size and backing DPI.
masks: Vec<Rect>,
+ pane_id: Option<PaneId>,
+ canvas_size: (f32, f32),
pub(crate) editing: bool,
selected: Option<usize>,
drag: Option<Drag>,
@@ -94,6 +154,41 @@ pub(crate) struct RecordingOverlay {
}
impl RecordingOverlay {
+ fn bind(&mut self, pane_id: PaneId, size: (f32, f32)) {
+ self.cancel_interaction();
+ self.pane_id = Some(pane_id);
+ self.canvas_size = size;
+ self.selected = None;
+ self.masks = pane_masks(pane_id)
+ .map(|masks| {
+ masks
+ .0
+ .lock()
+ .unwrap()
+ .iter()
+ .map(|r| Rect {
+ x: r.x * size.0,
+ y: r.y * size.1,
+ w: r.w * size.0,
+ h: r.h * size.1,
+ })
+ .collect()
+ })
+ .unwrap_or_default();
+ }
+
+ fn save(&self) {
+ if let Some(pane_id) = self.pane_id {
+ save_pane_masks(
+ pane_id,
+ self.masks
+ .iter()
+ .map(|r| r.normalized(self.canvas_size))
+ .collect(),
+ );
+ }
+ }
+
pub(crate) fn is_empty(&self) -> bool {
self.masks.is_empty()
}
@@ -105,6 +200,7 @@ impl RecordingOverlay {
self.masks.clear();
self.selected = None;
self.drag = None;
+ self.save();
}
pub(crate) fn cancel_interaction(&mut self) {
@@ -126,7 +222,7 @@ impl RecordingOverlay {
match index {
0 => true,
1 => self.selected.is_some(),
- 2 => !self.masks.is_empty(),
+ 2 => !self.is_empty(),
_ => false,
}
}
@@ -156,6 +252,7 @@ impl RecordingOverlay {
self.drag = None;
if let Some(index) = self.selected.take() {
self.masks.remove(index);
+ self.save();
}
}
@@ -231,6 +328,7 @@ impl RecordingOverlay {
self.masks[index] = drag.preview
}
}
+ self.save();
}
fn displayed(&self, index: usize, bounds: (f32, f32)) -> Rect {
@@ -245,7 +343,132 @@ impl RecordingOverlay {
}
impl crate::TermWindow {
+ fn recording_pane_frame(&self, pane_id: PaneId) -> Option<window::RectF> {
+ self.get_panes_to_render()
+ .iter()
+ .find(|pos| pos.pane.pane_id() == pane_id)
+ .and_then(|pos| self.pane_frame_rect(pos).ok())
+ }
+
+ pub(crate) fn active_pane_recording_masks_empty(&self) -> bool {
+ self.get_active_pane_or_overlay()
+ .is_none_or(|pane| pane_masks(pane.pane_id()).is_none_or(|masks| masks.is_empty()))
+ }
+
+ pub(crate) fn clear_active_pane_recording_masks(&mut self) {
+ if let Some(pane) = self.get_active_pane_or_overlay() {
+ save_pane_masks(pane.pane_id(), Vec::new());
+ if self.recording_overlay.pane_id == Some(pane.pane_id()) {
+ self.recording_overlay.clear();
+ }
+ crate::frontend::front_end().invalidate_all_windows();
+ }
+ }
+
+ // This runs inside the terminal world, so a recorded transition includes it.
+ pub(crate) fn paint_pane_recording_masks(
+ &self,
+ pane_id: PaneId,
+ frame: window::RectF,
+ layers: &mut TripleLayerQuadAllocator,
+ ) -> anyhow::Result<()> {
+ let black = LinearRgba::with_components(0.0, 0.0, 0.0, 1.0);
+ let editing =
+ self.recording_overlay.editing && self.recording_overlay.pane_id == Some(pane_id);
+ if !editing {
+ return self.paint_saved_recording_masks(pane_id, frame, frame, layers, 1.0);
+ }
+ let state = &self.recording_overlay;
+ let accent = self.chrome().accent;
+ for index in 0..state.masks.len() {
+ let rect = state
+ .displayed(index, state.canvas_size)
+ .normalized(state.canvas_size)
+ .in_frame(frame);
+ self.filled_rectangle(layers, 2, rect, black)?;
+ if state.selected == Some(index) {
+ self.fill_rounded_rectangle_with_border(
+ layers,
+ 2,
+ rect,
+ black,
+ accent,
+ 0.0,
+ self.ui_f32(1.0),
+ )?;
+ let side = self.ui_f32(6.0).min(rect.width()).min(rect.height());
+ self.fill_rounded_rectangle(
+ layers,
+ 2,
+ euclid::rect(rect.max_x() - side, rect.max_y() - side, side, side),
+ accent,
+ self.ui_f32(2.0),
+ )?;
+ }
+ }
+ if let Some(Drag {
+ kind: DragKind::Create,
+ preview,
+ ..
+ }) = state.drag
+ {
+ self.filled_rectangle(
+ layers,
+ 2,
+ preview.normalized(state.canvas_size).in_frame(frame),
+ black,
+ )?;
+ }
+ Ok(())
+ }
+
+ pub(crate) fn paint_saved_recording_masks(
+ &self,
+ pane_id: PaneId,
+ frame: window::RectF,
+ clip: window::RectF,
+ layers: &mut TripleLayerQuadAllocator,
+ opacity: f32,
+ ) -> anyhow::Result<()> {
+ if let Some(masks) = pane_masks(pane_id) {
+ self.paint_recording_mask_layer(&masks, frame, clip, layers, opacity)?;
+ }
+ Ok(())
+ }
+
+ pub(crate) fn paint_recording_mask_layer(
+ &self,
+ masks: &PaneRecordingLayer,
+ frame: window::RectF,
+ clip: window::RectF,
+ layers: &mut TripleLayerQuadAllocator,
+ opacity: f32,
+ ) -> anyhow::Result<()> {
+ for rect in masks.0.lock().unwrap().iter() {
+ if let Some(rect) = rect.in_frame(frame).intersection(&clip) {
+ self.filled_rectangle(
+ layers,
+ 2,
+ rect,
+ LinearRgba::with_components(0.0, 0.0, 0.0, opacity),
+ )?;
+ }
+ }
+ Ok(())
+ }
+
pub(crate) fn start_recording_overlay_edit(&mut self) {
+ let Some(pane) = self.get_active_pane_or_overlay() else {
+ return;
+ };
+ let Some(frame) = self.recording_pane_frame(pane.pane_id()) else {
+ return;
+ };
+ let scale = self.ui_f32(1.0).max(0.01);
+ self.recording_overlay.bind(
+ pane.pane_id(),
+ (frame.width() / scale, frame.height() / scale),
+ );
self.recording_overlay.editing = true;
self.recording_overlay.drag = None;
self.recording_overlay.pressed_button = None;
@@ -283,6 +506,7 @@ impl crate::TermWindow {
}
_ => {}
}
+ crate::frontend::front_end().invalidate_all_windows();
context.invalidate();
}
true
@@ -305,6 +529,22 @@ impl crate::TermWindow {
(event.coords.x as f32 / scale).clamp(0.0, bounds.0),
(event.coords.y as f32 / scale).clamp(0.0, bounds.1),
);
+ let frame = self
+ .recording_overlay
+ .pane_id
+ .and_then(|id| self.recording_pane_frame(id));
+ let Some(frame) = frame else {
+ self.recording_overlay.finish();
+ context.invalidate();
+ return true;
+ };
+ let canvas = self.recording_overlay.canvas_size;
+ let local = (
+ (event.coords.x as f32 - frame.min_x()) / frame.width().max(1.0) * canvas.0,
+ (event.coords.y as f32 - frame.min_y()) / frame.height().max(1.0) * canvas.1,
+ );
+ let inside = local.0 >= 0.0 && local.1 >= 0.0 && local.0 <= canvas.0 && local.1 <= canvas.1;
+ let local = (local.0.clamp(0.0, canvas.0), local.1.clamp(0.0, canvas.1));
let button = self
.recording_overlay
.buttons
@@ -325,13 +565,13 @@ impl crate::TermWindow {
} else if let Some(rect) = self.recording_overlay.toolbar {
self.recording_overlay.toolbar_drag = Some((point, rect));
}
- } else {
- self.recording_overlay.begin(point, bounds);
+ } else if inside {
+ self.recording_overlay.begin(local, canvas);
}
}
MouseEventKind::Move => {
self.recording_overlay.move_toolbar(point, bounds);
- self.recording_overlay.update_drag(point, bounds);
+ self.recording_overlay.update_drag(local, canvas);
}
MouseEventKind::Release(MousePress::Left) => {
if self.recording_overlay.toolbar_drag.is_some() {
@@ -347,7 +587,7 @@ impl crate::TermWindow {
}
}
} else {
- self.recording_overlay.update_drag(point, bounds);
+ self.recording_overlay.update_drag(local, canvas);
self.recording_overlay.commit_drag();
}
}
@@ -361,12 +601,12 @@ impl crate::TermWindow {
} else {
MouseCursor::Arrow
}
- } else if let Some(index) = self.recording_overlay.hit(point, bounds) {
+ } else if let Some(index) = self.recording_overlay.hit(local, canvas).filter(|_| inside) {
if self
.recording_overlay
- .displayed(index, bounds)
+ .displayed(index, canvas)
.handle()
- .contains(point)
+ .contains(local)
{
MouseCursor::SizeNorthWestSouthEast
} else {
@@ -375,13 +615,25 @@ impl crate::TermWindow {
} else {
MouseCursor::Arrow
};
+ if matches!(event.kind, MouseEventKind::Release(MousePress::Left)) {
+ crate::frontend::front_end().invalidate_all_windows();
+ }
context.set_cursor(Some(cursor));
context.invalidate();
true
}
pub(crate) fn paint_recording_overlay(&mut self) -> anyhow::Result<()> {
- if self.recording_overlay.is_empty() && !self.recording_overlay.editing {
+ if !self.recording_overlay.editing {
+ return Ok(());
+ }
+ if self
+ .recording_overlay
+ .pane_id
+ .and_then(|id| self.recording_pane_frame(id))
+ .is_none()
+ {
+ self.recording_overlay.finish();
return Ok(());
}
let scale = self.ui_f32(1.0).max(0.01);
@@ -393,52 +645,6 @@ impl crate::TermWindow {
let layer = gl.layer_for_zindex(OVERLAY_ZINDEX)?;
let mut layers = layer.quad_allocator();
let black = LinearRgba::with_components(0.0, 0.0, 0.0, 1.0);
- let accent = LinearRgba::with_components(0.15, 0.6, 1.0, 1.0);
- for index in 0..self.recording_overlay.masks.len() {
- let rect = self.recording_overlay.displayed(index, bounds);
- self.filled_rectangle(&mut layers, 0, rect.pixels(scale), black)?;
- if self.recording_overlay.editing {
- if self.recording_overlay.selected == Some(index) {
- self.fill_rounded_rectangle_with_border(
- &mut layers,
- 1,
- rect.pixels(scale),
- black,
- accent,
- 0.0,
- 1.0 * scale,
- )?;
- }
- if self.recording_overlay.selected == Some(index) {
- let handle = rect.handle();
- let dot = Rect {
- x: handle.x + handle.w - 7.0,
- y: handle.y + handle.h - 7.0,
- w: 6.0,
- h: 6.0,
- };
- self.fill_rounded_rectangle(
- &mut layers,
- 2,
- dot.pixels(scale),
- accent,
- 2.0 * scale,
- )?;
- }
- }
- }
- if let Some(Drag {
- kind: DragKind::Create,
- preview,
- ..
- }) = self.recording_overlay.drag
- {
- self.filled_rectangle(&mut layers, 0, preview.pixels(scale), black)?;
- }
- if !self.recording_overlay.editing {
- return Ok(());
- }
-
let size = (crate::native_settings::home_font_size(&crate::native_settings::load_shared())
* 0.8)
.max(10.0);
@@ -714,6 +920,73 @@ mod tests {
assert_eq!(state.displayed(0, (500.0, 400.0)), state.masks[0]);
}
+ #[test]
+ fn panes_own_independent_masks_and_other_windows_share_them() {
+ let a = usize::MAX - 10;
+ let b = usize::MAX - 11;
+ let mut editor = RecordingOverlay::default();
+ editor.bind(a, (500.0, 400.0));
+ editor.begin((100.0, 80.0), editor.canvas_size);
+ editor.update_drag((200.0, 160.0), editor.canvas_size);
+ editor.commit_drag();
+ editor.bind(b, (500.0, 400.0));
+ assert!(editor.is_empty());
+ editor.clear();
+ let mut other_window = RecordingOverlay::default();
+ other_window.bind(a, (1000.0, 800.0));
+ assert_eq!(
+ other_window.masks,
+ vec![Rect {
+ x: 200.0,
+ y: 160.0,
+ w: 200.0,
+ h: 160.0
+ }]
+ );
+ forget_pane(a);
+ forget_pane(b);
+ }
+
+ #[test]
+ fn cached_preview_sees_edits_and_retains_masks_until_picture_is_dropped() {
+ let id = usize::MAX - 12;
+ let cached = pane_layer(id);
+ assert!(cached.is_empty());
+ let rect = Rect {
+ x: 0.2,
+ y: 0.3,
+ w: 0.4,
+ h: 0.1,
+ };
+ save_pane_masks(id, vec![rect]);
+ assert_eq!(*cached.0.lock().unwrap(), vec![rect]);
+ save_pane_masks(id, vec![]);
+ assert!(cached.is_empty());
+ save_pane_masks(id, vec![rect]);
+ forget_pane(id);
+ assert!(pane_masks(id).is_none());
+ assert_eq!(*cached.0.lock().unwrap(), vec![rect]);
+ }
+
+ #[test]
+ fn normalized_mask_maps_into_terminal_and_overview_frames() {
+ let mask = Rect {
+ x: 100.0,
+ y: 80.0,
+ w: 200.0,
+ h: 40.0,
+ }
+ .normalized((1000.0, 400.0));
+ let terminal = mask.in_frame(euclid::rect(300.0, 100.0, 1000.0, 400.0));
+ assert_eq!(terminal, euclid::rect(400.0, 180.0, 200.0, 40.0));
+ let overview = mask.in_frame(euclid::rect(20.0, 50.0, 250.0, 100.0));
+ assert_eq!(overview, euclid::rect(45.0, 70.0, 50.0, 10.0));
+ assert_eq!(
+ overview.intersection(&euclid::rect(60.0, 50.0, 100.0, 100.0)),
+ Some(euclid::rect(60.0, 70.0, 35.0, 10.0))
+ );
+ }
+
#[test]
fn floating_toolbar_moves_independently_and_stays_reachable() {
let mut state = with_mask();