Skip to content

Macos fires WindowEvent::Focused(false) on WinitWindow creation #2695

@TimonPost

Description

@TimonPost

In this commit: b457329#diff-4803bb2335a17d700335730b9f62828e001faa602b9b894dff572422c737b78aR480 the author fires the Focused(false) event on macos window creation. It seems to be inconsistent with the other platforms.

In my case on macos I receive first Focused(true) and then Focused(false) when creating a window. The Focused(true) is caused by window_did_become_key and then Focused(false) is caused by the window init function queuing it when it is created.

On other platforms it seems like the focused boolean is automatically set to false upon creation without firing an event. This seems to create divergent behavior on different platforms as macos has an additional event now.

For now my fix is the following:

 WindowEvent::Focused(_focused) => {
        self.focused = winit.has_focus();
}

Sending an event on window creation creates unexpected behavior. Evenwhile my window is focused winit just informed me it isn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A - needs reprowaiting for a way to reproduceB - bugDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions