diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2023-12-19 20:59:23 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2023-12-19 21:17:35 +1300 |
commit | 1fb788cc09fa349957da501dd911435f1957c03a (patch) | |
tree | 88b83f10f56a4c9e8b333076f3776c616ac0036f /src | |
parent | 8e019fb17d49dd1d605e81a59a84febfd4fc41c8 (diff) | |
download | phosphor-1fb788cc09fa349957da501dd911435f1957c03a.zip |
Use logical position for cursor position
Previously the physical cursor position instead of the logical cursor
position was being passed to WindowController::on_cursor_move, which
meant that the cursor position that the application was receiving would
be incorrect when the window scale was greater than 1.
Diffstat (limited to 'src')
-rw-r--r-- | src/window.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/window.rs b/src/window.rs index 327cbea..fcb5b2a 100644 --- a/src/window.rs +++ b/src/window.rs @@ -126,11 +126,14 @@ impl Window { } pub fn move_cursor(&mut self, position: Point) { + // Convert cursor position from physical position to logical position. + let pixel_scale = self.controller.pixel_scale().get() as i32; + let logical_position = Point::new(position.x / pixel_scale, position.y / pixel_scale); // The cursor position is rounded to i32 from f64, so we need to ignore // duplicate consecutive cursor positions. - if self.previous_cursor_position != Some(position) { - self.previous_cursor_position = Some(position); - self.controller.on_cursor_move(position); + if self.previous_cursor_position != Some(logical_position) { + self.previous_cursor_position = Some(logical_position); + self.controller.on_cursor_move(logical_position); } } |