Skip to content

Commit

Permalink
Handle zero width or height (#315)
Browse files Browse the repository at this point in the history
* Avoid resizing when width or height is zero
  • Loading branch information
maxammann committed Aug 5, 2024
1 parent 3dcec8f commit c3201f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions maplibre-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
..
} => window_target.exit(),
WindowEvent::Resized(winit::dpi::PhysicalSize { width, height}) => {
if let Ok(map_context) = map.context_mut() {
let size = PhysicalSize::new(*width, *height).expect("window values should not be zero");
map_context.resize(size, scale_factor);
map.window().request_redraw();
// If height or width is zero, skip this resize event. This happens on Windows when minimizing the window.
if let Some(size) = PhysicalSize::new(*width, *height) {
if let Ok(map_context) = map.context_mut() {
map_context.resize(size, scale_factor);
map.window().request_redraw();
}
}
}
WindowEvent::ScaleFactorChanged { inner_size_writer, scale_factor: new_scale_factor } => {
Expand Down

0 comments on commit c3201f7

Please sign in to comment.