aboutsummaryrefslogtreecommitdiff
path: root/src/app/input/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/input/mod.rs')
-rw-r--r--src/app/input/mod.rs49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs
index c17f64cd..c9056109 100644
--- a/src/app/input/mod.rs
+++ b/src/app/input/mod.rs
@@ -286,31 +286,13 @@ impl App {
}
let handled_pane_double_click = self.handle_pane_double_click(mouse);
+ if !handled_pane_double_click {
+ self.focus_pane_before_mouse_press(mouse);
+ }
let previous_agent_panel_sort = self.state.agent_panel_sort;
let previous_settings_section = self.state.settings.section;
if !handled_pane_double_click {
- let right_button = matches!(
- mouse.kind,
- MouseEventKind::Down(MouseButton::Right)
- | MouseEventKind::Up(MouseButton::Right)
- | MouseEventKind::Drag(MouseButton::Right)
- );
- let intentional_pane_press = matches!(
- mouse.kind,
- MouseEventKind::Down(MouseButton::Left | MouseButton::Middle)
- );
- if !right_button
- && intentional_pane_press
- && matches!(self.state.mode, Mode::Terminal | Mode::Resize)
- {
- if let (Some(ws_idx), Some(info)) = (
- self.state.active,
- self.state.pane_at(mouse.column, mouse.row).cloned(),
- ) {
- self.focus_pane_internal_via_api(ws_idx, info.id);
- }
- }
if let Some(action) = self.state.handle_mouse(&mut self.terminal_runtimes, mouse) {
match action {
MouseAction::NewWorkspace => {
@@ -459,6 +441,31 @@ impl App {
}
}
+ fn focus_pane_before_mouse_press(&mut self, mouse: MouseEvent) {
+ if !matches!(self.state.mode, Mode::Terminal | Mode::Resize)
+ || !matches!(
+ mouse.kind,
+ MouseEventKind::Down(MouseButton::Left | MouseButton::Middle)
+ )
+ {
+ return;
+ }
+
+ let Some(pane_id) = self
+ .state
+ .pane_at(mouse.column, mouse.row)
+ .map(|info| info.id)
+ else {
+ return;
+ };
+ let Some(ws_idx) = self.state.active else {
+ return;
+ };
+
+ // Focus through the runtime API before an application can consume its press.
+ self.focus_pane_internal_via_api(ws_idx, pane_id);
+ }
+
fn handle_modified_url_click(&mut self, mouse: MouseEvent) -> bool {
if self.state.mode != Mode::Terminal
|| !matches!(mouse.kind, MouseEventKind::Down(MouseButton::Left))