mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Handle zero width or height (#315)
* Avoid resizing when width or height is zero
This commit is contained in:
parent
3dcec8f07b
commit
c3201f79e0
@ -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 } => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user