aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-07-04 21:40:16 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2018-07-06 07:30:37 -0700
commitcde1d8d1edb0c8001a28a2a674c46b5a581439db (patch)
tree7bba7af3bd80c2750764d53dfbd7fa59955e172e
parent07aaf05f7463a971e56de87e3b6b24e4153e5a98 (diff)
downloadalacritty-cde1d8d1edb0c8001a28a2a674c46b5a581439db.tar.gz
alacritty-cde1d8d1edb0c8001a28a2a674c46b5a581439db.zip
Fix incorrect cell side in selection
Previously the cell side of a selection with the mouse outside of the grid has been calculated by setting the `Side` to `Right` whenever the `X` of the mouse is bigger or equal to `window_width - padding_x`. However since the grid doesn't perfectly fit the window in most cases, there was an additional few pixels where the `Side` would be `Left`, resulting in the selection jumping around. To fix this the additional padding due to not perfectly fitting window size has been included in the calculation. The `X` position is now checked to be bigger or equal to `width - padding_x - extra_padding_x`. An important note is that this will need changing when the grid is centered inside the window, so extra padding is split up evenly. Once that change is merged the calculation required will be `width - padding_x - extra_padding_x / 2.`. This fixes #1412.
-rw-r--r--src/input.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs
index 90384198..2d647114 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -304,9 +304,11 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
let cell_x = x.saturating_sub(size_info.padding_x as usize) % size_info.cell_width as usize;
let half_cell_width = (size_info.cell_width / 2.0) as usize;
+ let additional_padding = (size_info.width - size_info.padding_x * 2.) % size_info.cell_width;
+ let end_of_grid = size_info.width - size_info.padding_x - additional_padding;
let cell_side = if cell_x > half_cell_width
// Edge case when mouse leaves the window
- || x as f32 >= size_info.width - size_info.padding_x
+ || x as f32 >= end_of_grid
{
Side::Right
} else {