aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-06-02 16:11:43 +0300
committerGitHub <noreply@github.com>2023-06-02 16:11:43 +0300
commit4b92388396c6da783809c7ce511b5cf6be8a0624 (patch)
tree5d5e30bc59063dabf4f2c36350a32d57e4b27eb7 /alacritty/src/event.rs
parentd94cb6be99b098b0084d0a54dc4e655cd9c0e47c (diff)
downloadr-alacritty-4b92388396c6da783809c7ce511b5cf6be8a0624.tar.gz
r-alacritty-4b92388396c6da783809c7ce511b5cf6be8a0624.tar.bz2
r-alacritty-4b92388396c6da783809c7ce511b5cf6be8a0624.zip
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.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index c10bfed9..5fac1ced 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -1193,16 +1193,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);