From c10ff1e41ff1b8aea45d87082e83a6fbf103c5cd Mon Sep 17 00:00:00 2001 From: Autumn Lamonte Date: Tue, 4 Jan 2022 21:00:59 -0600 Subject: [PATCH] fix nits --- wezterm-gui/src/termwindow/mouseevent.rs | 53 ++++++++++++------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs index 773155d0e..bdbddb1f4 100644 --- a/wezterm-gui/src/termwindow/mouseevent.rs +++ b/wezterm-gui/src/termwindow/mouseevent.rs @@ -117,25 +117,16 @@ impl super::TermWindow { // Perform click counting let button = mouse_press_to_tmb(press); + let click_position = ClickPosition { + column: x, + row: y, + x_pixel_offset, + y_pixel_offset, + }; + let click = match self.last_mouse_click.take() { - None => LastMouseClick::new( - button, - ClickPosition { - column: x, - row: y, - x_pixel_offset, - y_pixel_offset, - }, - ), - Some(click) => click.add( - button, - ClickPosition { - column: x, - row: y, - x_pixel_offset, - y_pixel_offset, - }, - ), + None => LastMouseClick::new(button, click_position), + Some(click) => click.add(button, click_position), }; self.last_mouse_click = Some(click); self.current_mouse_buttons.retain(|p| p != press); @@ -194,7 +185,17 @@ impl super::TermWindow { if let Some(item) = ui_item { self.mouse_event_ui_item(item, pane, y, event, context); } else { - self.mouse_event_terminal(pane, x, y, x_pixel_offset, y_pixel_offset, event, context); + self.mouse_event_terminal( + pane, + ClickPosition { + column: x, + row: y, + x_pixel_offset, + y_pixel_offset, + }, + event, + context, + ); } } @@ -452,18 +453,18 @@ impl super::TermWindow { } } - pub fn mouse_event_terminal( + fn mouse_event_terminal( &mut self, mut pane: Rc, - mut x: usize, - mut y: i64, - x_pixel_offset: usize, - y_pixel_offset: usize, + position: ClickPosition, event: MouseEvent, context: &dyn WindowOps, ) { let mut is_click_to_focus = false; + let mut x = position.column; + let mut y = position.row; + for pos in self.get_panes_to_render() { if y >= pos.top as i64 && y <= (pos.top + pos.height) as i64 @@ -718,8 +719,8 @@ impl super::TermWindow { }, x, y, - x_pixel_offset, - y_pixel_offset, + x_pixel_offset: position.x_pixel_offset, + y_pixel_offset: position.y_pixel_offset, modifiers: window_mods_to_termwiz_mods(event.modifiers), };