Skip to content

Return an Option from Window::raw_window_handle() + add WindowConfigured event #2769

@rib

Description

@rib

It's not great that the Android backend will simply panic if Window::raw_window_handle() is called while the app is suspended and it would be nicer if the API instead returned an Option to convey when no handle is currently available.

Winit could then promise/guarantee that a handle will always be available for RedrawRequested events and it would be platform-dependent whether a handle is also be accessible outside of redraw events.

This could potentially also benefit the Wayland backend which has to wait for an ack from the compositor before a raw handle should be accessible for creating graphics API surfaces after creating a new Window. (Right now the wayland backend has to synchronously wait for a compositor round trip in Window::new and this is also having a pretty significant impact on the backend's internal design because it needs to have a buffering abstraction to avoid a reentrancy problem)

To help give applications a natural place to initialize graphics API surfaces (i.e. egl,vulkan/wgpu surfaces) for new windows, then we could also add a WindowConfigured or WindowReady event that all backends will be guaranteed to dispatch once for any new window at the earliest point at which a raw-window-handle is accessible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S - apiDesign and usability

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions