Skip to content

Window: focus/blur (activation) events#36

Merged
codymullins merged 1 commit into
mainfrom
feat/focus-events
Jun 18, 2026
Merged

Window: focus/blur (activation) events#36
codymullins merged 1 commit into
mainfrom
feat/focus-events

Conversation

@codymullins

Copy link
Copy Markdown
Contributor

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 MinimizedChanged but not focus.

What changed

  • AppWindow.FocusChanged (Action, true = active) → IWindowBackend.FocusChanged.
  • GLFW backend — forwards Silk.NET's IWindow.FocusChanged.
  • AppKit backend — raises it from 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.slnx clean (0 warnings); Skyline.Apple builds clean on the macos workload.
  • Headless tests pass; windowed harness passes (87 checks); format-check.sh clean.
  • Coverage: GlfwWindowBackend 100%, AppWindow 96.9% (matches main). 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.

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.
Copilot AI review requested due to automatic review settings June 17, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants