aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDesuwa <desuwa@desuwa.net>2019-02-05 14:33:07 -0800
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-02-05 22:33:07 +0000
commit879ea05b6681ffce3e90526a89f3dc6b1dd1c424 (patch)
tree2b4868163625558869806023e4090105cee382f6
parent851e77383ea764b793914696b29b4e6d95632ebb (diff)
downloadalacritty-879ea05b6681ffce3e90526a89f3dc6b1dd1c424.tar.gz
alacritty-879ea05b6681ffce3e90526a89f3dc6b1dd1c424.zip
Scale IME position by hidpi_factor
Since the IME was positioned using physical coordinates, the location would be incorrect with monitors using a DPR other than 1.0. This has been resolved by converting the physical position to a logical position using the methods built into winit. Fixes #2056.
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/display.rs26
2 files changed, 16 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c37850a..01208769 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove error message when reloading an empty config
- Allow disabling URL launching by setting the value of `mouse.url.launcher` to `None`
- Corrected the `window.decorations` config documentation for macOS
+- Fix IME position on HiDPI displays
## Version 0.2.7
diff --git a/src/display.rs b/src/display.rs
index d5a8978b..2e4e741a 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -18,7 +18,7 @@ use std::sync::mpsc;
use std::f64;
use parking_lot::MutexGuard;
-use glutin::dpi::{LogicalPosition, PhysicalSize};
+use glutin::dpi::{PhysicalPosition, PhysicalSize};
use crate::cli;
use crate::config::Config;
@@ -488,15 +488,19 @@ impl Display {
/// Adjust the IME editor position according to the new location of the cursor
pub fn update_ime_position(&mut self, terminal: &Term) {
- use crate::index::{Column, Line, Point};
- use crate::term::SizeInfo;
- let Point{line: Line(row), col: Column(col)} = terminal.cursor().point;
- let SizeInfo{cell_width: cw,
- cell_height: ch,
- padding_x: px,
- padding_y: py, ..} = *terminal.size_info();
- let nspot_y = (py + (row + 1) as f32 * ch) as i32;
- let nspot_x = (px + col as f32 * cw) as i32;
- self.window().set_ime_spot(LogicalPosition::from((nspot_x, nspot_y)));
+ let point = terminal.cursor().point;
+ let SizeInfo {
+ cell_width: cw,
+ cell_height: ch,
+ padding_x: px,
+ padding_y: py,
+ ..
+ } = *terminal.size_info();
+
+ let dpr = self.window().hidpi_factor();
+ let nspot_x = f64::from(px + point.col.0 as f32 * cw);
+ let nspot_y = f64::from(py + (point.line.0 + 1) as f32 * ch);
+
+ self.window().set_ime_spot(PhysicalPosition::from((nspot_x, nspot_y)).to_logical(dpr));
}
}