aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/window.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-01-10 01:51:37 +0000
committerGitHub <noreply@github.com>2020-01-10 01:51:37 +0000
commitc34ec12c309695e4c14d8e50b5f3f54198f70775 (patch)
treef88bee2818c0208fc288de3d7f9b283cc9c7077b /alacritty/src/window.rs
parentdd1413eb4d4f8cb170458155e5156e569c14130e (diff)
downloadr-alacritty-c34ec12c309695e4c14d8e50b5f3f54198f70775.tar.gz
r-alacritty-c34ec12c309695e4c14d8e50b5f3f54198f70775.tar.bz2
r-alacritty-c34ec12c309695e4c14d8e50b5f3f54198f70775.zip
Bump glutin to 0.22.0
Fixes #3165.
Diffstat (limited to 'alacritty/src/window.rs')
-rw-r--r--alacritty/src/window.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 33594741..4d1a8ead 100644
--- a/alacritty/src/window.rs
+++ b/alacritty/src/window.rs
@@ -18,9 +18,7 @@ use std::fmt::{self, Display, Formatter};
#[cfg(not(any(target_os = "macos", windows)))]
use std::os::raw::c_ulong;
-#[cfg(not(windows))]
-use glutin::dpi::PhysicalPosition;
-use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
+use glutin::dpi::{PhysicalPosition, PhysicalSize};
use glutin::event_loop::EventLoop;
#[cfg(target_os = "macos")]
use glutin::platform::macos::{RequestUserAttentionType, WindowBuilderExtMacOS, WindowExtMacOS};
@@ -105,7 +103,7 @@ fn create_gl_window(
mut window: WindowBuilder,
event_loop: &EventLoop<Event>,
srgb: bool,
- dimensions: Option<LogicalSize>,
+ dimensions: Option<PhysicalSize<u32>>,
) -> Result<WindowedContext<PossiblyCurrent>> {
if let Some(dimensions) = dimensions {
window = window.with_inner_size(dimensions);
@@ -139,12 +137,12 @@ impl Window {
pub fn new(
event_loop: &EventLoop<Event>,
config: &Config,
- logical: Option<LogicalSize>,
+ size: Option<PhysicalSize<u32>>,
) -> Result<Window> {
let window_builder = Window::get_platform_window(&config.window.title, &config.window);
let windowed_context =
- create_gl_window(window_builder.clone(), &event_loop, false, logical)
- .or_else(|_| create_gl_window(window_builder, &event_loop, true, logical))?;
+ create_gl_window(window_builder.clone(), &event_loop, false, size)
+ .or_else(|_| create_gl_window(window_builder, &event_loop, true, size))?;
// Text cursor
let current_mouse_cursor = CursorIcon::Text;
@@ -166,16 +164,16 @@ impl Window {
Ok(Self { current_mouse_cursor, mouse_visible: true, windowed_context })
}
- pub fn set_inner_size(&mut self, size: LogicalSize) {
+ pub fn set_inner_size(&mut self, size: PhysicalSize<u32>) {
self.window().set_inner_size(size);
}
- pub fn inner_size(&self) -> LogicalSize {
+ pub fn inner_size(&self) -> PhysicalSize<u32> {
self.window().inner_size()
}
- pub fn hidpi_factor(&self) -> f64 {
- self.window().hidpi_factor()
+ pub fn scale_factor(&self) -> f64 {
+ self.window().scale_factor()
}
#[inline]
@@ -301,7 +299,7 @@ impl Window {
#[cfg(windows)]
pub fn set_urgent(&self, _is_urgent: bool) {}
- pub fn set_outer_position(&self, pos: LogicalPosition) {
+ pub fn set_outer_position(&self, pos: PhysicalPosition<u32>) {
self.window().set_outer_position(pos);
}
@@ -367,20 +365,19 @@ impl Window {
#[cfg(not(windows))]
pub fn update_ime_position<T>(&mut self, terminal: &Term<T>, size_info: &SizeInfo) {
let point = terminal.cursor().point;
- let SizeInfo { cell_width: cw, cell_height: ch, padding_x: px, padding_y: py, dpr, .. } =
- size_info;
+ let SizeInfo { cell_width, cell_height, padding_x, padding_y, .. } = size_info;
- 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);
+ 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);
- self.window().set_ime_position(PhysicalPosition::from((nspot_x, nspot_y)).to_logical(*dpr));
+ self.window().set_ime_position(PhysicalPosition::new(nspot_x, nspot_y));
}
pub fn swap_buffers(&self) {
self.windowed_context.swap_buffers().expect("swap buffers");
}
- pub fn resize(&self, size: PhysicalSize) {
+ pub fn resize(&self, size: PhysicalSize<u32>) {
self.windowed_context.resize(size);
}