-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WindowEvent::Resized report outer size on iOS #2347
Copy link
Copy link
Closed
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - uikitAffects the UIKit backend (iOS, tvOS, watchOS, visionOS)Affects the UIKit backend (iOS, tvOS, watchOS, visionOS)
Description
When starting any applications using winit on iOS, I'm receiving a WindowEvent::Resized coming from layout_subviews corresponding to the full size of the screen instead of the inner size.
I currently workaround this by using Window::inner_size when handling that event.
winit/src/platform_impl/ios/view.rs
Lines 119 to 151 in 44288f6
| extern "C" fn layout_subviews(object: &Object, _: Sel) { | |
| unsafe { | |
| let superclass: &'static Class = msg_send![object, superclass]; | |
| let _: () = msg_send![super(object, superclass), layoutSubviews]; | |
| let window: id = msg_send![object, window]; | |
| assert!(!window.is_null()); | |
| let window_bounds: CGRect = msg_send![window, bounds]; | |
| let screen: id = msg_send![window, screen]; | |
| let screen_space: id = msg_send![screen, coordinateSpace]; | |
| let screen_frame: CGRect = | |
| msg_send![object, convertRect:window_bounds toCoordinateSpace:screen_space]; | |
| let scale_factor: CGFloat = msg_send![screen, scale]; | |
| let size = crate::dpi::LogicalSize { | |
| width: screen_frame.size.width as f64, | |
| height: screen_frame.size.height as f64, | |
| } | |
| .to_physical(scale_factor as f64); | |
| // If the app is started in landscape, the view frame and window bounds can be mismatched. | |
| // The view frame will be in portrait and the window bounds in landscape. So apply the | |
| // window bounds to the view frame to make it consistent. | |
| let view_frame: CGRect = msg_send![object, frame]; | |
| if view_frame != window_bounds { | |
| let _: () = msg_send![object, setFrame: window_bounds]; | |
| } | |
| app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::WindowEvent { | |
| window_id: RootWindowId(window.into()), | |
| event: WindowEvent::Resized(size), | |
| })); | |
| } | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - uikitAffects the UIKit backend (iOS, tvOS, watchOS, visionOS)Affects the UIKit backend (iOS, tvOS, watchOS, visionOS)