From 1c86d3e2e53d64146a6ca1bc1e4ec57310b5d0a1 Mon Sep 17 00:00:00 2001 From: frederik-uni <147479464+frederik-uni@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:05:08 +0200 Subject: [PATCH 1/3] remove black bar on iOS winit::Window::inner_size returns size of safe area on iOS. use winit::Window::outer_size on iOS --- crates/egui-winit/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 1980376b97a..3998e6f4153 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -36,6 +36,9 @@ use winit::{ }; pub fn screen_size_in_pixels(window: &Window) -> egui::Vec2 { + #[cfg(target_os = "ios")] + let size = window.outer_size(); + #[cfg(not(target_os = "ios"))] let size = window.inner_size(); egui::vec2(size.width as f32, size.height as f32) } From ba771fa84a0d7198ca63184d9fba587caa2a47d7 Mon Sep 17 00:00:00 2001 From: frederik-uni <147479464+frederik-uni@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:43:37 +0200 Subject: [PATCH 2/3] Accept changes from emilk Co-authored-by: Emil Ernerfeldt --- crates/egui-winit/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 3998e6f4153..70848af03e6 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -36,10 +36,14 @@ use winit::{ }; pub fn screen_size_in_pixels(window: &Window) -> egui::Vec2 { - #[cfg(target_os = "ios")] - let size = window.outer_size(); - #[cfg(not(target_os = "ios"))] - let size = window.inner_size(); + let size = if cfg!(target_os = "ios") { + // `outer_size` Includes the area behind the "dynamic island". + // It is up to the eframe user to make sure the dynamic island doesn't cover anything important. + // That will be easier once https://github.com/rust-windowing/winit/pull/3890 lands + window.outer_size(); + } else { + window.inner_size() + }; egui::vec2(size.width as f32, size.height as f32) } From 72b28f6bc3a2318a0b4d27ee07849c3a34d703e9 Mon Sep 17 00:00:00 2001 From: frederik-uni <147479464+frederik-uni@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:53:40 +0200 Subject: [PATCH 3/3] format and remove ; --- crates/egui-winit/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 70848af03e6..a78339d01fe 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -39,11 +39,11 @@ pub fn screen_size_in_pixels(window: &Window) -> egui::Vec2 { let size = if cfg!(target_os = "ios") { // `outer_size` Includes the area behind the "dynamic island". // It is up to the eframe user to make sure the dynamic island doesn't cover anything important. - // That will be easier once https://github.com/rust-windowing/winit/pull/3890 lands - window.outer_size(); + // That will be easier once https://github.com/rust-windowing/winit/pull/3890 lands + window.outer_size() } else { - window.inner_size() - }; + window.inner_size() + }; egui::vec2(size.width as f32, size.height as f32) }