Clicking Dock icon fails to bring up Control pane while kiosk is running #1

Closed
opened 2026-10-14 07:40:42 +00:00 by xrisk · 0 comments
Owner

Summary

When TV Dashboard is running with the kiosk active on an external TV display (e.g. over AirPlay), clicking the app's Dock icon fails to bring up, restore, or focus the "TV Dashboard — Control" window.

Context / Environment

  • OS: macOS
  • Display Setup: AirPlay display connected to an external TV, running kiosk surface (KioskWindow on .screenSaver level).
  • Application State: App running in Dock with active indicator dot, kiosk displaying on TV.

Steps to Reproduce

  1. Launch TV Dashboard and start the kiosk display on an external TV via AirPlay.
  2. Close the "TV Dashboard — Control" window (using the red window close button) or minimize / hide it behind other application windows on the Mac.
  3. Click the TV Dashboard icon in the macOS Dock.

Expected Behavior

Clicking the Dock icon should bring the "TV Dashboard — Control" pane to the front on the Mac's built-in/primary display, deminiaturizing it if minimized and ordering it front/key (makeKeyAndOrderFront).

Actual Behavior

Nothing happens. The Dock icon bounces/activates, but the control pane is not displayed or brought forward. Because KioskWindow is pinned to the TV and does not accept key/main focus, the operator has no easy way to reopen the control pane without relaunching or finding another workaround.

Root Cause Analysis

In Sources/TVDashboard/AppDelegate.swift:

  1. NSApplicationDelegate does not implement applicationShouldHandleReopen(_:hasVisibleWindows:).
  2. When the Dock icon is clicked, Cocoa queries applicationShouldHandleReopen. Because KioskWindow is currently open and visible on the external TV screen, hasVisibleWindows evaluates to true.
  3. By default, macOS does not restore or unhide closed windows when hasVisibleWindows is true. Even when hasVisibleWindows is false, default Cocoa behavior only unminimizes miniaturized windows; it does not re-open closed windows (even with isReleasedWhenClosed = false).
  4. Since KioskWindow.canBecomeKey and canBecomeMain are both false, standard window focus traversal also does not bring adminWindow forward.

Suggested Fix

Implement applicationShouldHandleReopen(_:hasVisibleWindows:) in AppDelegate.swift:

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
    guard let window = adminWindow else { return true }
    if window.isMiniaturized {
        window.deminiaturize(nil)
    }
    window.makeKeyAndOrderFront(nil)
    NSApp.activate(ignoringOtherApps: true)
    return true
}

Optionally, also add a "Show Control Panel" menu item to NSApp.mainMenu (and/or dock menu applicationDockMenu(_:)) to ensure the control pane can always be reopened via keyboard shortcut or right-clicking the Dock icon.

### Summary When TV Dashboard is running with the kiosk active on an external TV display (e.g. over AirPlay), clicking the app's Dock icon fails to bring up, restore, or focus the "TV Dashboard — Control" window. ### Context / Environment - **OS**: macOS - **Display Setup**: AirPlay display connected to an external TV, running kiosk surface (`KioskWindow` on `.screenSaver` level). - **Application State**: App running in Dock with active indicator dot, kiosk displaying on TV. ### Steps to Reproduce 1. Launch TV Dashboard and start the kiosk display on an external TV via AirPlay. 2. Close the "TV Dashboard — Control" window (using the red window close button) or minimize / hide it behind other application windows on the Mac. 3. Click the TV Dashboard icon in the macOS Dock. ### Expected Behavior Clicking the Dock icon should bring the "TV Dashboard — Control" pane to the front on the Mac's built-in/primary display, deminiaturizing it if minimized and ordering it front/key (`makeKeyAndOrderFront`). ### Actual Behavior Nothing happens. The Dock icon bounces/activates, but the control pane is not displayed or brought forward. Because `KioskWindow` is pinned to the TV and does not accept key/main focus, the operator has no easy way to reopen the control pane without relaunching or finding another workaround. ### Root Cause Analysis In `Sources/TVDashboard/AppDelegate.swift`: 1. `NSApplicationDelegate` does not implement `applicationShouldHandleReopen(_:hasVisibleWindows:)`. 2. When the Dock icon is clicked, Cocoa queries `applicationShouldHandleReopen`. Because `KioskWindow` is currently open and visible on the external TV screen, `hasVisibleWindows` evaluates to `true`. 3. By default, macOS does not restore or unhide closed windows when `hasVisibleWindows` is `true`. Even when `hasVisibleWindows` is `false`, default Cocoa behavior only unminimizes miniaturized windows; it does not re-open closed windows (even with `isReleasedWhenClosed = false`). 4. Since `KioskWindow.canBecomeKey` and `canBecomeMain` are both `false`, standard window focus traversal also does not bring `adminWindow` forward. ### Suggested Fix Implement `applicationShouldHandleReopen(_:hasVisibleWindows:)` in `AppDelegate.swift`: ```swift func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { guard let window = adminWindow else { return true } if window.isMiniaturized { window.deminiaturize(nil) } window.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) return true } ``` Optionally, also add a "Show Control Panel" menu item to `NSApp.mainMenu` (and/or dock menu `applicationDockMenu(_:)`) to ensure the control pane can always be reopened via keyboard shortcut or right-clicking the Dock icon.
xrisk closed this issue 2026-10-14 08:27:37 +00:00
Sign in to join this conversation.
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#1
No description provided.