summaryrefslogtreecommitdiff
path: root/x11-terms/alacritty/files/alacritty-0.4.1-fix-winit.patch
blob: cff76b0ec237748787389271195b460767271c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
From c454e5dad003fad2983191d8a5cfe9461c85177c Mon Sep 17 00:00:00 2001
From: Georgy Yakovlev <gyakovlev@gentoo.org>
Date: Thu, 9 Jan 2020 23:14:57 -0800
Subject: [PATCH] use release versions of glutin and winit

also partial backport of c34ec12c309695e4c14d8e50b5f3f54198f70775
---
 Cargo.lock                      | 18 ++++---
 Cargo.toml                      |  1 -
 alacritty/Cargo.toml            |  2 +-
 alacritty/src/display.rs        | 24 ++++-----
 alacritty/src/event.rs          | 88 ++++++++++++++++-----------------
 alacritty/src/input.rs          | 11 +++--
 alacritty/src/renderer/mod.rs   |  4 +-
 alacritty/src/window.rs         | 33 ++++++-------
 alacritty_terminal/src/event.rs |  1 +
 9 files changed, 89 insertions(+), 93 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index dfb07c5..57e53b6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -33,7 +33,7 @@ dependencies = [
  "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "font 0.1.0",
  "gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "glutin 0.22.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glutin 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -752,7 +752,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "glutin"
-version = "0.22.0-alpha5"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -773,7 +773,7 @@ dependencies = [
  "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winit 0.20.0-alpha6 (git+https://github.com/rust-windowing/winit?rev=d1c6506865c7bddbb5fb4d80a613e43ddc1370b5)",
+ "winit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2293,12 +2293,11 @@ dependencies = [
 
 [[package]]
 name = "winit"
-version = "0.20.0-alpha6"
-source = "git+https://github.com/rust-windowing/winit?rev=d1c6506865c7bddbb5fb4d80a613e43ddc1370b5#d1c6506865c7bddbb5fb4d80a613e43ddc1370b5"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "calloop 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "cocoa 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2308,10 +2307,13 @@ dependencies = [
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
+ "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
  "smithay-client-toolkit 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2494,7 +2496,7 @@ dependencies = [
 "checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a"
 "checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
 "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
-"checksum glutin 0.22.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)" = "4f29f0d8e02e304b15a4464118387dcad1f543695057a60276a196311cc93452"
+"checksum glutin 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c40ccddfa5fb8aaad6a152bfa6b17f157d6635928a832211534f87c9877e1"
 "checksum glutin_egl_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c"
 "checksum glutin_emscripten_sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "245b3fdb08df6ffed7585365851f8404af9c7e2dd4b59f15262e968b6a95a0c7"
 "checksum glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89996c30857ae1b4de4b5189abf1ea822a20a9fe9e1c93e5e7b862ff0bdd5cdf"
@@ -2675,7 +2677,7 @@ dependencies = [
 "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 "checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9"
-"checksum winit 0.20.0-alpha6 (git+https://github.com/rust-windowing/winit?rev=d1c6506865c7bddbb5fb4d80a613e43ddc1370b5)" = "<none>"
+"checksum winit 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba128780050481f453bec2a115b916dbc6ae79c303dee9bad8b9080bdccd4f5"
 "checksum winpty-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dade7ecea144b3578a02925f93900f32370abfb8768630883971f4ef716b568"
 "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
 "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
diff --git a/Cargo.toml b/Cargo.toml
index bb50a3d..2e8fd4d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,3 @@ incremental = false
 
 [patch.crates-io]
 servo-freetype-sys = { path = "servo-freetype-proxy" }
-winit = { git = "https://github.com/rust-windowing/winit", rev = "d1c6506865c7bddbb5fb4d80a613e43ddc1370b5" }
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index 84ea1bf..07837b4 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -18,7 +18,7 @@ fnv = "1"
 serde = { version = "1", features = ["derive"] }
 serde_yaml = "0.8"
 serde_json = "1"
-glutin = "0.22.0-alpha5"
+glutin = { version = "0.22.0", features = ["serde"] }
 notify = "4"
 libc = "0.2"
 unicode-width = "0.1"
diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs
index e02381e..cd526d9 100644
--- a/alacritty/src/display.rs
+++ b/alacritty/src/display.rs
@@ -124,7 +124,7 @@ impl Display {
     pub fn new(config: &Config, event_loop: &EventLoop<Event>) -> Result<Display, Error> {
         // Guess DPR based on first monitor
         let estimated_dpr =
-            event_loop.available_monitors().next().map(|m| m.hidpi_factor()).unwrap_or(1.);
+            event_loop.available_monitors().next().map(|m| m.scale_factor()).unwrap_or(1.);
 
         // Guess the target window dimensions
         let metrics = GlyphCache::static_metrics(config.font.clone(), estimated_dpr)?;
@@ -137,16 +137,16 @@ impl Display {
         debug!("Estimated Dimensions: {:?}", dimensions);
 
         // Create the window where Alacritty will be displayed
-        let logical = dimensions.map(|d| PhysicalSize::new(d.0, d.1).to_logical(estimated_dpr));
+        let size = dimensions.map(|(width, height)| PhysicalSize::new(width, height));
 
         // Spawn window
-        let mut window = Window::new(event_loop, &config, logical)?;
+        let mut window = Window::new(event_loop, &config, size)?;
 
-        let dpr = window.hidpi_factor();
+        let dpr = window.scale_factor();
         info!("Device pixel ratio: {}", dpr);
 
         // get window properties for initializing the other subsystems
-        let mut viewport_size = window.inner_size().to_physical(dpr);
+        let viewport_size = window.inner_size();
 
         // Create renderer
         let mut renderer = QuadRenderer::new()?;
@@ -160,12 +160,11 @@ impl Display {
         if let Some((width, height)) =
             GlyphCache::calculate_dimensions(config, dpr, cell_width, cell_height)
         {
-            let PhysicalSize { width: w, height: h } = window.inner_size().to_physical(dpr);
-            if (w - width).abs() < f64::EPSILON && (h - height).abs() < f64::EPSILON {
+            let PhysicalSize { width: w, height: h } = window.inner_size();
+            if w == width && h == height {
                 info!("Estimated DPR correctly, skipping resize");
             } else {
-                viewport_size = PhysicalSize::new(width, height);
-                window.set_inner_size(viewport_size.to_logical(dpr));
+                window.set_inner_size(PhysicalSize::new(width, height));
             }
         } else if config.window.dynamic_padding {
             // Make sure additional padding is spread evenly
@@ -217,9 +216,7 @@ impl Display {
         // TODO: replace `set_position` with `with_position` once available
         // Upstream issue: https://github.com/tomaka/winit/issues/806
         if let Some(position) = config.window.position {
-            let physical = PhysicalPosition::from((position.x, position.y));
-            let logical = physical.to_logical(dpr);
-            window.set_outer_position(logical);
+            window.set_outer_position(PhysicalPosition::from((position.x, position.y)));
         }
 
         #[allow(clippy::single_match)]
@@ -341,8 +338,7 @@ impl Display {
         terminal.resize(&pty_size);
 
         // Resize renderer
-        let physical =
-            PhysicalSize::new(f64::from(self.size_info.width), f64::from(self.size_info.height));
+        let physical = PhysicalSize::new(self.size_info.width as u32, self.size_info.height as u32);
         self.window.resize(physical);
         self.renderer.resize(&self.size_info);
     }
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index d03c439..74ba88b 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -6,11 +6,12 @@ use std::env;
 use std::fs;
 use std::fs::File;
 use std::io::Write;
+use std::mem;
 use std::sync::Arc;
 use std::time::Instant;
 
 use glutin::dpi::PhysicalSize;
-use glutin::event::{ElementState, Event as GlutinEvent, ModifiersState, MouseButton};
+use glutin::event::{ElementState, Event as GlutinEvent, ModifiersState, MouseButton, WindowEvent};
 use glutin::event_loop::{ControlFlow, EventLoop, EventLoopProxy};
 use glutin::platform::desktop::EventLoopExtDesktop;
 use log::{debug, info, warn};
@@ -42,7 +43,7 @@ use crate::window::Window;
 
 #[derive(Default, Clone, Debug, PartialEq)]
 pub struct DisplayUpdate {
-    pub dimensions: Option<PhysicalSize>,
+    pub dimensions: Option<PhysicalSize<u32>>,
     pub message_buffer: Option<()>,
     pub font: Option<Font>,
 }
@@ -349,7 +350,12 @@ impl<N: Notify + OnResize> Processor<N> {
                 info!("glutin event: {:?}", event);
             }
 
-            match &event {
+            // Ignore all events we do not care about
+            if Self::skip_event(&event) {
+                return;
+            }
+
+            match event {
                 // Check for shutdown
                 GlutinEvent::UserEvent(Event::Exit) => {
                     *control_flow = ControlFlow::Exit;
@@ -363,12 +369,22 @@ impl<N: Notify + OnResize> Processor<N> {
                         return;
                     }
                 },
-                // Buffer events
-                _ => {
+                // Remap DPR change event to remove lifetime
+                GlutinEvent::WindowEvent {
+                    event: WindowEvent::ScaleFactorChanged { scale_factor, new_inner_size },
+                    ..
+                } => {
                     *control_flow = ControlFlow::Poll;
-                    if !Self::skip_event(&event) {
-                        event_queue.push(event);
-                    }
+                    let size = (new_inner_size.width, new_inner_size.height);
+                    let event = GlutinEvent::UserEvent(Event::DPRChanged(scale_factor, size));
+                    event_queue.push(event);
+                    return;
+                },
+                // Transmute to extend lifetime, which exists only for `ScaleFactorChanged` event.
+                // Since we remap that event to remove the lifetime, this is safe.
+                event => unsafe {
+                    *control_flow = ControlFlow::Poll;
+                    event_queue.push(mem::transmute(event));
                     return;
                 },
             }
@@ -443,6 +459,18 @@ impl<N: Notify + OnResize> Processor<N> {
     {
         match event {
             GlutinEvent::UserEvent(event) => match event {
+                Event::DPRChanged(scale_factor, (width, height)) => {
+                    let display_update_pending = &mut processor.ctx.display_update_pending;
+
+                    // Push current font to update its DPR
+                    display_update_pending.font = Some(processor.ctx.config.font.clone());
+
+                    // Resize to event's dimensions, since no resize event is emitted on Wayland
+                    display_update_pending.dimensions = Some(PhysicalSize::new(width, height));
+
+                    processor.ctx.size_info.dpr = scale_factor;
+                    processor.ctx.terminal.dirty = true;
+                },
                 Event::Title(title) => processor.ctx.window.set_title(&title),
                 Event::Wakeup => processor.ctx.terminal.dirty = true,
                 Event::Urgent => {
@@ -483,20 +511,19 @@ impl<N: Notify + OnResize> Processor<N> {
                 use glutin::event::WindowEvent::*;
                 match event {
                     CloseRequested => processor.ctx.terminal.exit(),
-                    Resized(lsize) => {
+                    Resized(size) => {
                         #[cfg(windows)]
                         {
                             // Minimizing the window sends a Resize event with zero width and
                             // height. But there's no need to ever actually resize to this.
                             // Both WinPTY & ConPTY have issues when resizing down to zero size
                             // and back.
-                            if lsize.width == 0.0 && lsize.height == 0.0 {
+                            if size.width == 0 && size.height == 0 {
                                 return;
                             }
                         }
 
-                        let psize = lsize.to_physical(processor.ctx.size_info.dpr);
-                        processor.ctx.display_update_pending.dimensions = Some(psize);
+                        processor.ctx.display_update_pending.dimensions = Some(size);
                         processor.ctx.terminal.dirty = true;
                     },
                     KeyboardInput { input, .. } => {
@@ -516,10 +543,10 @@ impl<N: Notify + OnResize> Processor<N> {
                             processor.ctx.terminal.dirty = true;
                         }
                     },
-                    CursorMoved { position: lpos, .. } => {
-                        let (x, y) = lpos.to_physical(processor.ctx.size_info.dpr).into();
-                        let x: i32 = limit(x, 0, processor.ctx.size_info.width as i32);
-                        let y: i32 = limit(y, 0, processor.ctx.size_info.height as i32);
+                    CursorMoved { position, .. } => {
+                        let (x, y) = position.into();
+                        let x = limit(x, 0, processor.ctx.size_info.width as i32);
+                        let y = limit(y, 0, processor.ctx.size_info.height as i32);
 
                         processor.ctx.window.set_mouse_visible(true);
                         processor.mouse_moved(x as usize, y as usize);
@@ -546,26 +573,6 @@ impl<N: Notify + OnResize> Processor<N> {
                         let path: String = path.to_string_lossy().into();
                         processor.ctx.write_to_pty(path.into_bytes());
                     },
-                    HiDpiFactorChanged(dpr) => {
-                        let dpr_change = (dpr / processor.ctx.size_info.dpr) as f32;
-                        let display_update_pending = &mut processor.ctx.display_update_pending;
-
-                        // Push current font to update its DPR
-                        display_update_pending.font = Some(processor.ctx.config.font.clone());
-
-                        // Scale window dimensions with new DPR
-                        let old_width = processor.ctx.size_info.width;
-                        let old_height = processor.ctx.size_info.height;
-                        let dimensions =
-                            display_update_pending.dimensions.get_or_insert_with(|| {
-                                PhysicalSize::new(f64::from(old_width), f64::from(old_height))
-                            });
-                        dimensions.width *= f64::from(dpr_change);
-                        dimensions.height *= f64::from(dpr_change);
-
-                        processor.ctx.terminal.dirty = true;
-                        processor.ctx.size_info.dpr = dpr;
-                    },
                     CursorLeft { .. } => {
                         processor.ctx.mouse.inside_grid = false;
 
@@ -574,6 +581,7 @@ impl<N: Notify + OnResize> Processor<N> {
                         }
                     },
                     TouchpadPressure { .. }
+                    | ScaleFactorChanged { .. }
                     | CursorEntered { .. }
                     | AxisMotion { .. }
                     | HoveredFileCancelled
@@ -602,7 +610,6 @@ impl<N: Notify + OnResize> Processor<N> {
     /// Check if an event is irrelevant and can be skipped
     fn skip_event(event: &GlutinEvent<Event>) -> bool {
         match event {
-            GlutinEvent::UserEvent(Event::Exit) => true,
             GlutinEvent::WindowEvent { event, .. } => {
                 use glutin::event::WindowEvent::*;
                 match event {
@@ -617,13 +624,6 @@ impl<N: Notify + OnResize> Processor<N> {
                     _ => false,
                 }
             },
-            GlutinEvent::DeviceEvent { event, .. } => {
-                use glutin::event::DeviceEvent::*;
-                match event {
-                    ModifiersChanged { .. } => false,
-                    _ => true,
-                }
-            },
             GlutinEvent::Suspended { .. }
             | GlutinEvent::NewEvents { .. }
             | GlutinEvent::MainEventsCleared
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index 08383ea..246dd7a 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -972,6 +972,7 @@ mod tests {
                 let urls = Urls::new();
                 let mut processor = Processor::new(context, &urls, &None);
 
+                let event: Event::<'_, TerminalEvent> = $input;
                 if let Event::WindowEvent {
                     event: WindowEvent::MouseInput {
                         state,
@@ -979,7 +980,7 @@ mod tests {
                         ..
                     },
                     ..
-                } = $input
+                } = event
                 {
                     processor.mouse_input(state, button);
                 };
@@ -1015,7 +1016,7 @@ mod tests {
         name: single_click,
         initial_state: ClickState::None,
         initial_button: MouseButton::Other(0),
-        input: Event::<TerminalEvent>::WindowEvent {
+        input: Event::WindowEvent {
             event: WindowEvent::MouseInput {
                 state: ElementState::Pressed,
                 button: MouseButton::Left,
@@ -1032,7 +1033,7 @@ mod tests {
         name: double_click,
         initial_state: ClickState::Click,
         initial_button: MouseButton::Left,
-        input: Event::<TerminalEvent>::WindowEvent {
+        input: Event::WindowEvent {
             event: WindowEvent::MouseInput {
                 state: ElementState::Pressed,
                 button: MouseButton::Left,
@@ -1049,7 +1050,7 @@ mod tests {
         name: triple_click,
         initial_state: ClickState::DoubleClick,
         initial_button: MouseButton::Left,
-        input: Event::<TerminalEvent>::WindowEvent {
+        input: Event::WindowEvent {
             event: WindowEvent::MouseInput {
                 state: ElementState::Pressed,
                 button: MouseButton::Left,
@@ -1066,7 +1067,7 @@ mod tests {
         name: multi_click_separate_buttons,
         initial_state: ClickState::DoubleClick,
         initial_button: MouseButton::Left,
-        input: Event::<TerminalEvent>::WindowEvent {
+        input: Event::WindowEvent {
             event: WindowEvent::MouseInput {
                 state: ElementState::Pressed,
                 button: MouseButton::Right,
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
index 6084723..d5d48b4 100644
--- a/alacritty/src/renderer/mod.rs
+++ b/alacritty/src/renderer/mod.rs
@@ -358,7 +358,7 @@ impl GlyphCache {
         dpr: f64,
         cell_width: f32,
         cell_height: f32,
-    ) -> Option<(f64, f64)> {
+    ) -> Option<(u32, u32)> {
         let dimensions = config.window.dimensions;
 
         if dimensions.columns_u32() == 0
@@ -378,7 +378,7 @@ impl GlyphCache {
         let width = padding_x.mul_add(2., f64::from(grid_width)).floor();
         let height = padding_y.mul_add(2., f64::from(grid_height)).floor();
 
-        Some((width, height))
+        Some((width as u32, height as u32))
     }
 }
 
diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs
index 3359474..4d1a8ea 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);
     }
 
diff --git a/alacritty_terminal/src/event.rs b/alacritty_terminal/src/event.rs
index 2d43e9d..c8edae1 100644
--- a/alacritty_terminal/src/event.rs
+++ b/alacritty_terminal/src/event.rs
@@ -6,6 +6,7 @@ use crate::term::SizeInfo;
 
 #[derive(Clone, Debug, PartialEq)]
 pub enum Event {
+    DPRChanged(f64, (u32, u32)),
     ConfigReload(PathBuf),
     MouseCursorDirty,
     Message(Message),
-- 
2.24.1