1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-27 15:37:29 +03:00

fix mouse x position calc in tab bar

close: https://github.com/wez/wezterm/issues/677
This commit is contained in:
Wez Furlong 2021-04-25 19:55:36 -07:00
parent f3706c706c
commit f3679b024d

View File

@ -27,17 +27,6 @@ impl super::TermWindow {
self.current_mouse_event.replace(event.clone());
let config = &self.config;
// Round the x coordinate so that we're a bit more forgiving of
// the horizontal position when selecting cells
let x = ((event
.coords
.x
.sub(config.window_padding.left as isize)
.max(0) as f32)
/ self.render_metrics.cell_size.width as f32)
.round()
.trunc() as usize;
// But don't round the y coordinate as that is more annoying
let y = (event
.coords
.y
@ -47,10 +36,25 @@ impl super::TermWindow {
let first_line_offset = if self.show_tab_bar { 1 } else { 0 };
let was_in_tab_bar = self.show_tab_bar && self.last_mouse_coords.1 == 0;
let in_tab_bar = self.show_tab_bar && y == 0 && event.coords.y >= 0;
let x = (event
.coords
.x
.sub(config.window_padding.left as isize)
.max(0) as f32)
/ self.render_metrics.cell_size.width as f32;
let x = if !in_tab_bar {
// Round the x coordinate so that we're a bit more forgiving of
// the horizontal position when selecting cells
x.round()
} else {
x
}
.trunc() as usize;
self.last_mouse_coords = (x, y);
let in_tab_bar = self.show_tab_bar && y == 0 && event.coords.y >= 0;
let in_scroll_bar = self.show_scroll_bar && x >= self.terminal_size.cols as usize;
// y position relative to top of viewport (not including tab bar)
let term_y = y.saturating_sub(first_line_offset);