Skip to content

Scene phases#489

Draft
kaascevich wants to merge 7 commits intomoreSwift:mainfrom
kaascevich:scene-phase
Draft

Scene phases#489
kaascevich wants to merge 7 commits intomoreSwift:mainfrom
kaascevich:scene-phase

Conversation

@kaascevich
Copy link
Contributor

@kaascevich kaascevich commented Mar 15, 2026

Adds a scenePhase environment value and associated types and backend functions.

  • If the property is declared on the App struct, it returns active if the app as a whole is active, or inactive otherwise. (For GTK and WinUI, this simply checks if any of the app's windows are active; for AppKit and UIKit it checks the appropriate property of NS/UIApplication.shared.)
  • If the property is declared on a View, it returns active if the enclosing window is active, or inactive otherwise.

This resolves #488.

Currently, there are only two scene states: active and inactive. We can consider adding a background state to match SwiftUI, though that'd require some extra bikeshedding on the exact behavior of background on desktop platforms -- personally I'd prefer to leave that for a future PR, but if it's important enough to add it now we can add it now.

Implemented backends

The property itself

  • AppKitBackend
  • GtkBackend
  • Gtk3Backend
  • UIKitBackend
  • WinUIBackend

Rerendering when scene phase changes

  • AppKitBackend
  • GtkBackend (only for individual windows, not the whole app)
  • Gtk3Backend (only for individual windows, not the whole app)
  • UIKitBackend
  • WinUIBackend

@MiaKoring
Copy link
Contributor

what is the problem with rerendering on UIKit and WinUI? /cur

@kaascevich
Copy link
Contributor Author

kaascevich commented Mar 15, 2026

AFAIK there isn’t any, I just haven’t gotten around to it yet.

@MiaKoring
Copy link
Contributor

ah, okay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scene phase

2 participants