Skip to content

macOS regresssion: new window starts on top of fullscreen window #2051

@emilk

Description

@emilk

Reproduce: Run VSCode in fullscreen mode, and in the VSCode terminal enter cargo run --example window (in the winit repo).

Expected (and actual in winit 0.24):

The view changes to the desktop and the winit window opens there.

Actual:

The winit window pops up over the fullscreen VSCode, and then the view changes to the desktop (where there is no window).

When did this break?

Work-arounds

Add the following code to after you create the event loop, but before creating your window:

    #[cfg(target_os = "macos")]
    unsafe {
        // work-around for https://github.com/rust-windowing/winit/issues/2051
        use cocoa::appkit::NSApplication as _;
        cocoa::appkit::NSApp().setActivationPolicy_(
            cocoa::appkit::NSApplicationActivationPolicy::NSApplicationActivationPolicyRegular,
        );
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backendH - help wantedSomeone please save us

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions