Skip to content

Focused issue when creating multiple new windows at once. #1077

@hardiesoft

Description

@hardiesoft

I have noticed different behavior of when the WindowEvent::Focused(bool) event is dispatched, depending whether you are on Windows or MacOS.

I've modified the multiwindow example here to illustrate these differences:

On running the example on windows I get the following output:
New window WindowId(WindowId(0x40e7a))
New window WindowId(WindowId(0x30edc))
Lost focus: WindowId(WindowId(0x40e7a))

On macos, I get:
New window WindowId(Id(140494821671056))
New window WindowId(Id(140494818628096))
Got focus: WindowId(Id(140494818628096))

The windows example seems more wrong than the macos example, since we never get an event for the second window that gained focus when the first window lost it.

Depending on your point of view though, the macos example could also be wrong if we're aiming for consistency with the model that each window gains focus when it is created, and loses it when another one is created afterwards.

I'm happy to put together a PR for this issue, but I'd first like to start some discussion around what the correct behavior should be.

As an aside, I also think winit is missing an APIs to programmatically set window focus and to control stacking order of windows. If it's agreed that those pieces of functionality are in scope for winit, then I'll write up issues for them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedC - needs investigationIssue must be confirmed and researchedDS - appkitAffects the AppKit/macOS backendDS - waylandAffects the Wayland backend, or generally free Unix platformsDS - win32Affects the Win32/Windows backendDS - x11Affects the X11 backend, or generally free Unix platformsS - platform parityUnintended platform differences

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions