Skip to content

WindowEvent::Focused(false) emitted on startup on macOS #4371

@emilk

Description

@emilk

Description

In winit v0.30.12, one of the first emitted events is WindowEvent::Focused(false), despite the window getting focus on start. Calling widow.has_focus() yields the correct true.

Switching away from the winit app (with cmd-tab) yields another WindowEvent::Focused(false).
Only when switching back to the winit app do we get the first WindowEvent::Focused(true).

Interestingly, this is NOT an issue on latest master.
With winit 0.31 having no due-date, I think this would be nice to fix in 0.30.x.

Repro: cargo r --example window

macOS version

ProductName:            macOS
ProductVersion:         26.0.1
BuildVersion:           25A362

Winit version

0.30.12

Related

I found this old pair of issue/PR:

Seems like we have a regression.

Workaround

Ignore the value of WindowEvent::Focused and only trust window.has_focus()

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happened

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions