aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/window.rs')
-rw-r--r--alacritty/src/window.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 3319dce8..92fedc86 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -137,6 +137,9 @@ pub struct Window {
#[cfg(not(any(target_os = "macos", windows)))]
pub wayland_surface: Option<Attached<WlSurface>>,
+ /// Cached DPR for quickly scaling pixel sizes.
+ pub dpr: f64,
+
windowed_context: WindowedContext<PossiblyCurrent>,
current_mouse_cursor: CursorIcon,
mouse_visible: bool,
@@ -192,6 +195,8 @@ impl Window {
wayland_surface = Some(proxy.attach(wayland_event_queue.as_ref().unwrap().token()));
}
+ let dpr = windowed_context.window().scale_factor();
+
Ok(Self {
current_mouse_cursor,
mouse_visible: true,
@@ -200,6 +205,7 @@ impl Window {
should_draw: Arc::new(AtomicBool::new(true)),
#[cfg(not(any(target_os = "macos", windows)))]
wayland_surface,
+ dpr,
})
}
@@ -211,10 +217,6 @@ impl Window {
self.window().inner_size()
}
- pub fn scale_factor(&self) -> f64 {
- self.window().scale_factor()
- }
-
#[inline]
pub fn set_visible(&self, visibility: bool) {
self.window().set_visible(visibility);
@@ -387,11 +389,9 @@ impl Window {
/// Adjust the IME editor position according to the new location of the cursor.
#[cfg(not(windows))]
- pub fn update_ime_position(&mut self, point: Point, size_info: &SizeInfo) {
- let SizeInfo { cell_width, cell_height, padding_x, padding_y, .. } = size_info;
-
- let nspot_x = f64::from(padding_x + point.col.0 as f32 * cell_width);
- let nspot_y = f64::from(padding_y + (point.line.0 + 1) as f32 * cell_height);
+ pub fn update_ime_position(&mut self, point: Point, size: &SizeInfo) {
+ let nspot_x = f64::from(size.padding_x() + point.col.0 as f32 * size.cell_width());
+ let nspot_y = f64::from(size.padding_y() + (point.line.0 + 1) as f32 * size.cell_height());
self.window().set_ime_position(PhysicalPosition::new(nspot_x, nspot_y));
}