rust-windowing / rust-windowing/winit

Move `can_create_surfaces()`/`destroy_surfaces()` from `ApplicationHandler` to `WindowEvent`

Open
#4,420 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C - needs discussion
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

It has been brought up in many issues over the years, that winit to this day doesn't support multiple Activitys on Android. I've always envisioned them to be analogous to a system-created window (i.e. needing a new ApplicationHandler::window_created(new_window: Window) callback of sorts) that the user could possibly launch themselves asynchronously with https://github.com/rust-mobile/android-intent.

As brought up again in https://github.com/rust-windowing/winit/pull/4419 this requires the surface events to be moved to WindowEvent as they're strictly related to a single Activity (thus winit Window) for which the underlying presentation surface (a layer in the composition stack/tree of sorts) is created or destroyed.

Looking through the current examples, it completely eludes me why can_create_surfaces() has been the selected place to create new windows now, as that is entirely counter to what the original Event::Resumed used/intended to represent. On winit's Android backend, a Window is anyway a bogus concept that doesn't really represent anything right now.

Is that something we can move and resolve before winit 0.31 is finalized and released, allowing Android to possibly "catch up" without breaking core/API releases - and if anything to demonstrate the right semantics in at least our examples/documentation/guidelines?

Related downstream confusion

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ApplicationHandler and WindowEvent APIs, then trace the Android backend's surface events and the current examples. Review the related pull request and existing issue discussion before deciding the API shape. Done means the surface events are associated with the relevant WindowEvent and the examples, documentation, or guidelines demonstrate the intended semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, mobile-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.