diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-21 21:27:20 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-21 21:27:20 +0300 |
| commit | 1f2f939862a399e8655d9ce99ab644faf6a32d17 (patch) | |
| tree | af2046db96c194462e9d47f3b8d651cf4efb35b3 /src/app/input | |
| parent | 866aaf740e10fcfce169aaf81380ea0257fbe272 (diff) | |
fix: keep notifications below floating overlays
refs #228
Diffstat (limited to 'src/app/input')
| -rw-r--r-- | src/app/input/mouse.rs | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/app/input/mouse.rs b/src/app/input/mouse.rs index 4d49a917..9e54fce1 100644 --- a/src/app/input/mouse.rs +++ b/src/app/input/mouse.rs @@ -62,14 +62,16 @@ impl AppState { return None; } - if self.clickable_toast_at(mouse.column, mouse.row) + if self.mode == Mode::Terminal + && self.clickable_toast_at(mouse.column, mouse.row) && matches!(mouse.kind, MouseEventKind::Down(MouseButton::Left)) { self.focus_toast_target(); return None; } - if self.clickable_toast_at(mouse.column, mouse.row) + if self.mode == Mode::Terminal + && self.clickable_toast_at(mouse.column, mouse.row) && matches!(mouse.kind, MouseEventKind::Up(MouseButton::Left)) { return None; @@ -1457,6 +1459,40 @@ mod tests { } #[test] + fn toast_click_does_not_steal_mouse_from_settings_overlay() { + let mut app = app_for_mouse_test(); + let active = Workspace::test_new("active"); + let background = Workspace::test_new("background"); + let target_pane = background.tabs[0].root_pane; + let workspace_id = background.id.clone(); + + app.state.workspaces = vec![active, background]; + app.state.active = Some(0); + app.state.selected = 0; + app.state.toast = Some(crate::app::state::ToastNotification { + kind: crate::app::state::ToastKind::Finished, + title: "pi finished".into(), + context: "background ยท 2".into(), + target: Some(crate::app::state::ToastTarget { + workspace_id, + pane_id: target_pane, + }), + }); + app.state.mode = Mode::Settings; + crate::ui::compute_view(&mut app.state, Rect::new(0, 0, 106, 20)); + + let hit = app.state.view.toast_hit_area; + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Left), + hit.x + 1, + hit.y + 1, + )); + + assert_eq!(app.state.active, Some(0)); + assert!(app.state.toast.is_some()); + } + + #[test] fn clicking_confirm_close_accepts_workspace_close() { let mut app = app_for_mouse_test(); app.state.workspaces = vec![Workspace::test_new("a"), Workspace::test_new("b")]; |
