fix: restore and bring forward control pane on Dock icon click (fixes #1) #2

Merged
xrisk merged 1 commit from fix_issue_one into main 2026-10-14 08:27:37 +00:00
Owner

Resolves #1

Summary

When TV Dashboard is running with the kiosk active on an external TV display (or in a fullscreen local Space), clicking the Dock icon failed to bring up, restore, or focus the "TV Dashboard — Control" window if closed, minimized, or behind other windows.

Because KioskWindow is pinned to the TV at .screenSaver level and cannot become key/main (canBecomeKey = false, canBecomeMain = false), Cocoa considers the application to have visible windows (hasVisibleWindows == true). In that state, default Cocoa behavior does not restore closed windows or deminiaturize windows.

Changes

  1. AppDelegate.swift:
    • Implemented applicationShouldHandleReopen(_:hasVisibleWindows:) to call showControlPanel().
    • Added showControlPanel(_:) which deminiaturizes (if minimized), calls makeKeyAndOrderFront, and activates the application. Also re-centers the window on the built-in/main screen if its screen was disconnected while closed.
    • Implemented applicationDockMenu(_:) to provide "Show Control Panel" when right-clicking the Dock icon.
    • Added a "Show Control Panel" menu item with keyboard shortcut ⌘0 to NSApp.mainMenu.
  2. SelfTest.swift:
    • Added automated tests verifying nil-safety, showControlPanel restoring visibility from a closed state, applicationShouldHandleReopen restoring visibility with hasVisibleWindows: true and false, and dock menu item presence.
  3. .wiki/wiki/references/task-routing.md:
    • Documented the Dock reopen, Dock context menu, and ⌘0 escape hatch contracts.

Verification

  • make test passed cleanly (SELFTEST OK, RUNTIME OK).
Resolves #1 ### Summary When TV Dashboard is running with the kiosk active on an external TV display (or in a fullscreen local Space), clicking the Dock icon failed to bring up, restore, or focus the "TV Dashboard — Control" window if closed, minimized, or behind other windows. Because `KioskWindow` is pinned to the TV at `.screenSaver` level and cannot become key/main (`canBecomeKey = false`, `canBecomeMain = false`), Cocoa considers the application to have visible windows (`hasVisibleWindows == true`). In that state, default Cocoa behavior does not restore closed windows or deminiaturize windows. ### Changes 1. **`AppDelegate.swift`**: - Implemented `applicationShouldHandleReopen(_:hasVisibleWindows:)` to call `showControlPanel()`. - Added `showControlPanel(_:)` which deminiaturizes (if minimized), calls `makeKeyAndOrderFront`, and activates the application. Also re-centers the window on the built-in/main screen if its screen was disconnected while closed. - Implemented `applicationDockMenu(_:)` to provide "Show Control Panel" when right-clicking the Dock icon. - Added a "Show Control Panel" menu item with keyboard shortcut `⌘0` to `NSApp.mainMenu`. 2. **`SelfTest.swift`**: - Added automated tests verifying nil-safety, `showControlPanel` restoring visibility from a closed state, `applicationShouldHandleReopen` restoring visibility with `hasVisibleWindows: true` and `false`, and dock menu item presence. 3. **`.wiki/wiki/references/task-routing.md`**: - Documented the Dock reopen, Dock context menu, and `⌘0` escape hatch contracts. ### Verification - `make test` passed cleanly (`SELFTEST OK`, `RUNTIME OK`).
Implement NSApplicationDelegate.applicationShouldHandleReopen(_:hasVisibleWindows:)
so clicking the Dock icon restores and focuses the 'TV Dashboard — Control'
window while the kiosk is running. Additionally implement applicationDockMenu(_:)
and add a ⌘0 shortcut in NSApp.mainMenu.

Fixes #1
xrisk merged commit cc03766db7 into main 2026-10-14 08:27:37 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
xrisk/tvd!2
No description provided.