diff options
author | Lado Tonia <ladotonia@gmail.com> | 2019-03-04 11:20:15 -0500 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-03-04 16:20:15 +0000 |
commit | 104b866cb6fa1b0674abdd2bdd3668f280939ca8 (patch) | |
tree | cdab953bf99b023461c8c10a5ee42a600bac467b /src | |
parent | 1ca729487e56e4f50d83790af4ef60e4f40b398f (diff) | |
download | alacritty-104b866cb6fa1b0674abdd2bdd3668f280939ca8.tar.gz alacritty-104b866cb6fa1b0674abdd2bdd3668f280939ca8.zip |
Fix selection starting inside padding
This fixes #2109.
Diffstat (limited to 'src')
-rw-r--r-- | src/input.rs | 2 | ||||
-rw-r--r-- | src/term/mod.rs | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/input.rs b/src/input.rs index 7779dca9..32e4dcbd 100644 --- a/src/input.rs +++ b/src/input.rs @@ -411,7 +411,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { } else if self.ctx.terminal().mode().intersects(motion_mode) // Only report motion when changing cells && (prev_line != self.ctx.mouse().line || prev_col != self.ctx.mouse().column) - && size_info.contains_point(x, y) + && size_info.contains_point(x, y, false) { if self.ctx.mouse().left_button_state == ElementState::Pressed { self.mouse_report(32, ElementState::Pressed, modifiers); diff --git a/src/term/mod.rs b/src/term/mod.rs index 966ac182..30a1a214 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -838,11 +838,15 @@ impl SizeInfo { Column(((self.width - 2. * self.padding_x) / self.cell_width) as usize) } - pub fn contains_point(&self, x: usize, y:usize) -> bool { - x < (self.width - self.padding_x) as usize - && x >= self.padding_x as usize - && y < (self.height - self.padding_y) as usize - && y >= self.padding_y as usize + pub fn contains_point(&self, x: usize, y: usize, include_padding: bool) -> bool { + if include_padding { + x < self.width as usize && y < self.height as usize + } else { + x < (self.width - self.padding_x) as usize + && x >= self.padding_x as usize + && y < (self.height - self.padding_y) as usize + && y >= self.padding_y as usize + } } pub fn pixels_to_coords(&self, x: usize, y: usize) -> Point { @@ -1104,9 +1108,10 @@ impl Term { /// The mouse coordinates are expected to be relative to the top left. The /// line and column returned are also relative to the top left. /// - /// Returns None if the coordinates are outside the screen + /// Returns None if the coordinates are outside the window, + /// padding pixels are considered inside the window pub fn pixels_to_coords(&self, x: usize, y: usize) -> Option<Point> { - if self.size_info.contains_point(x, y) { + if self.size_info.contains_point(x, y, true) { Some(self.size_info.pixels_to_coords(x, y)) } else { None |