Window: focus/blur (activation) events#36
Merged
Merged
Conversation
Add AppWindow.FocusChanged (true = active) so a shell can pause animation, timers, and media while the window is blurred and resume on focus. - GLFW backend forwards Silk.NET's IWindow.FocusChanged. - AppKit backend raises it from windowDidBecomeKey / windowDidResignKey. Addresses #10 (the focus/blur part). The occlusion signal is macOS-only (NSWindow.occlusionState) with no GLFW equivalent, so it does not fit the shared backend seam and is left as follow-up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #10 (the focus/blur part).
A browser pauses animation, timers, and media playback when its window loses focus and resumes on activation. Skyline reported
MinimizedChangedbut not focus.What changed
AppWindow.FocusChanged(Action, true = active) →IWindowBackend.FocusChanged.IWindow.FocusChanged.windowDidBecomeKey:/windowDidResignKey:(the same delegate pattern already used for miniaturize).Scope
Focus/blur is delivered on both backends. The issue also mentions an occlusion signal — that's macOS-only (
NSWindow.occlusionState) with no GLFW equivalent, so it doesn't fit the shared backend seam cleanly (adding an event GLFW never raises would trip the no-unused-event rule). Left as follow-up, so #10 stays open. Used "Addresses".Verification
dotnet build Skyline.slnxclean (0 warnings);Skyline.Applebuilds clean on the macos workload.format-check.shclean.GlfwWindowBackend100%,AppWindow96.9% (matchesmain). The ctor wiring lines are covered; overall 98% unchanged.Honest caveat
The firing of focus events can't be exercised headlessly (there's no way to synthesize an OS focus change in the test harness) — same situation as the existing GLFW input callbacks. The wiring compiles on both backends and the registration lines are covered; verifying the events actually fire needs a hands-on run with a real window.
Note
Touches the window seam, so it overlaps #30/#31/#32/#34 in
IWindowBackend/AppWindow/GLFW/FakeBackend. Edits are in distinct regions — trivial rebases as PRs land.