Skip to content

Keep the dashboard on its display across sleep and unplug - #30

Open
edward-mcnair wants to merge 1 commit into
kemalandic:mainfrom
edward-mcnair:fix-display-reconnect
Open

edward-mcnair wants to merge 1 commit into
kemalandic:mainfrom
edward-mcnair:fix-display-reconnect

Conversation

@edward-mcnair

Copy link
Copy Markdown

What does this PR do?

When the chosen display disappeared (unplugged, or slow to re-enumerate after sleep), refreshDisplays() fell back to the first screen and wrote that screen's name over the saved choice. The dashboard moved to another monitor and stayed there after the display came back, until relaunch.

With Stay on Target Display on, the filter also excluded NSScreen.main, which is the screen holding the key window, not the menu-bar screen. Once the dashboard was key, its own display stopped being eligible.

  • The saved display is never replaced by a fallback; availability is resolved separately (DisplaySelection).
  • Strict mode matches the named display directly, whether or not it is NSScreen.main, and hides the window while the display is absent.
  • While waiting, touch is released, and it's taken back when the display returns.
  • Placement retries carry a generation, so a retry from an older topology change, sleep or wake can't act after a newer one.

Tests: DisplaySelectionTests (7 cases: unplug, empty wake topology, new display ID and order, focused target, first launch).

Verified on a MacBook with two Studio Displays and a XENEON EDGE: unplug and replug, sleep and wake.

Screenshots

No UI change.

Checklist

  • Tested on macOS 14+ (macOS 27)
  • No third-party dependencies added
  • Follows existing code style (swift-format lint clean)

Note: built with swiftc and the new tests run with Swift Testing from the Command Line Tools. Xcode isn't installed on this machine, so CI is the first xcodebuild run.

🤖 Generated with Claude Code

When the chosen display disappeared (unplugged, or slow to come back after
sleep), refreshDisplays() fell back to the first screen and wrote that
screen's name over the user's choice, so the dashboard moved to another
monitor and stayed there after the display returned. With "Stay on Target
Display" on, the filter also excluded NSScreen.main, which is the screen
with the key window: once the dashboard was key, its own display stopped
being eligible.

- The saved display is never replaced by a fallback; availability is
  resolved separately (DisplaySelection).
- Strict mode matches the named display directly, whether or not it is
  NSScreen.main, and hides the window while it's absent.
- While waiting, touch is released and taken back when the display returns.
- Retries carry a generation, so a retry from an older topology change,
  sleep or wake can't act after a newer one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edward-mcnair

Copy link
Copy Markdown
Author

Hi @kemalandic — when you have a moment, could you approve the CI workflows for this PR and for #31 and #32? As a first-time contributor from a fork, GitHub holds their checks until a maintainer approves them ("Approve and run" on each PR).

Each one is independent and mergeable on its own. They're formatted with the repo's .swift-format and compile without warnings here; the new tests ran with Swift Testing outside Xcode, so CI will be the first full xcodebuild run. I'll fix anything it turns up. Thanks!

@edward-mcnair

Copy link
Copy Markdown
Author

Hi @kemalandic,

I was dying to get the XENEON EDGE, but it was PC only. When I heard about the software you created, I had Amazon deliver one the next day. I was thrilled that the software was open source, so I started vibe coding modifications to have it do what I was looking for.

I hope you like some of the updates, and that you and others might find them useful. I most certainly do. Each PR (#30–#32 and #34–#42) is small and independent, so feel free to take any of them on their own, or none at all.

Thank you for building this!

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.

1 participant