From fc918c2f4d2bfcfa3f5d1add33966e4594dff0a8 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 25 Oct 2019 07:20:21 -0700 Subject: [PATCH] don't panic when minimizing the window on Windows closes: https://github.com/wez/wezterm/issues/45 --- src/frontend/glium/window.rs | 7 +++++++ src/frontend/software/termwindow.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/frontend/glium/window.rs b/src/frontend/glium/window.rs index 47be0e3f1..621218624 100644 --- a/src/frontend/glium/window.rs +++ b/src/frontend/glium/window.rs @@ -178,6 +178,13 @@ impl TerminalWindow for GliumTerminalWindow { .ok_or_else(|| format_err!("failed to get inner window size"))?; let dpi_scale = self.host.display.gl_window().get_hidpi_factor(); let (width, height): (u32, u32) = size.to_physical(dpi_scale).into(); + + if width == 0 || height == 0 { + // on windows, this can happen when minimizing the window. + // NOP! + return Ok(()); + } + debug!( "resize {}x{}@{} -> {}x{}@{}", self.width, self.height, old_dpi_scale, width, height, dpi_scale diff --git a/src/frontend/software/termwindow.rs b/src/frontend/software/termwindow.rs index 7dbb48b45..d1e657539 100644 --- a/src/frontend/software/termwindow.rs +++ b/src/frontend/software/termwindow.rs @@ -738,6 +738,11 @@ impl WindowCallbacks for TermWindow { } fn resize(&mut self, dimensions: Dimensions) { + if dimensions.pixel_width == 0 || dimensions.pixel_height == 0 { + // on windows, this can happen when minimizing the window. + // NOP! + return; + } self.scaling_changed(dimensions, self.fonts.get_font_scale()); }