summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-06-02 16:11:43 +0300
committerKirill Chibisov <contact@kchibisov.com>2023-06-26 13:42:07 +0400
commit0e6ce4523b0ef6ee2f7e2f055e2cc55490009e86 (patch)
tree56e0ef24733c3ceeee7c59e5c1cab1331f3520e7
parent284f2c49a9a61ca9b6dabc6513448b528108227c (diff)
Fix crash on ScaleFactorChange on Windows
Windows is known to send zero sizes from winit in Risezed and now in ScaleFactorChanged events. They were handled in Resized, but not in ScaleFactorChanged. Fixes #6949.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs14
2 files changed, 11 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4096bb18..89a47167 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Hyperlink preview not being shown when the terminal has exactly 2 lines
+- Crash on Windows when changing display scale factor
## 0.12.1
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 9a27963c..5f0f05c1 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -1179,16 +1179,22 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> {
match event {
WinitEvent::UserEvent(Event { payload, .. }) => match payload {
EventType::ScaleFactorChanged(scale_factor, (width, height)) => {
+ self.ctx.window().scale_factor = scale_factor;
+
let display_update_pending = &mut self.ctx.display.pending_update;
// Push current font to update its scale factor.
let font = self.ctx.config.font.clone();
display_update_pending.set_font(font.with_size(*self.ctx.font_size));
- // Resize to event's dimensions, since no resize event is emitted on Wayland.
- display_update_pending.set_dimensions(PhysicalSize::new(width, height));
-
- self.ctx.window().scale_factor = scale_factor;
+ // Ignore resize events to zero in any dimension, to avoid issues with Winit
+ // and the ConPTY. A 0x0 resize will also occur when the window is minimized
+ // on Windows.
+ if width != 0 && height != 0 {
+ // Resize to event's dimensions, since no resize event is emitted on
+ // Wayland.
+ display_update_pending.set_dimensions(PhysicalSize::new(width, height));
+ }
},
EventType::Frame => {
self.ctx.display.window.has_frame.store(true, Ordering::Relaxed);