macOS/iOS: Remove window activation hacks (#3872)

No longer necessary after a8c7109 and facb809.
This commit is contained in:
Mads Marquart 2024-08-18 23:50:10 +02:00 committed by GitHub
parent a61e7bb4f4
commit 6c4da19197
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 113 deletions

View file

@ -78,6 +78,11 @@ impl WinitUIWindow {
frame: CGRect,
view_controller: &UIViewController,
) -> Retained<Self> {
// NOTE: This should only be created after the application has started launching,
// (`application:willFinishLaunchingWithOptions:` at the earliest), otherwise you'll run
// into very confusing issues with the window not being properly activated.
//
// Winit ensures this by not allowing access to `ActiveEventLoop` before handling events.
let this: Retained<Self> = unsafe { msg_send_id![mtm.alloc(), initWithFrame: frame] };
this.setRootViewController(Some(view_controller));
@ -490,8 +495,7 @@ impl Window {
let view_controller = WinitViewController::new(mtm, &window_attributes, &view);
let window = WinitUIWindow::new(mtm, &window_attributes, frame, &view_controller);
app_state::set_key_window(mtm, &window);
window.makeKeyAndVisible();
// Like the Windows and macOS backends, we send a `ScaleFactorChanged` and `Resized`
// event on window creation if the DPI factor != 1.0