Skip to content

Commit

Permalink
Workaround iOS resize bug with winit
Browse files Browse the repository at this point in the history
  • Loading branch information
marysaka committed Jun 26, 2022
1 parent 0541526 commit ed302ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,20 @@ pub fn rui(view: impl View) {
},
..
} => {
// On iOS it appears that winit returns the outer size of the window when resizing.
// Do not trust it and use inner_size explicitly.
// See https://github.com/rust-windowing/winit/issues/2347
if cfg!(target_os = "ios") {
let size = window.inner_size();

config.width = size.width.max(1);
config.height = size.height.max(1);
} else {
config.width = size.width.max(1);
config.height = size.height.max(1);
}

// println!("Resizing to {:?}", size);
config.width = size.width.max(1);
config.height = size.height.max(1);
surface.configure(&device, &config);
window.request_redraw();
}
Expand Down

0 comments on commit ed302ae

Please sign in to comment.