Skip to content

Commit 41efff4

Browse files
authored
fix: use CGMainDisplayID() instead of NSScreen.main for primary display detection (#21)
NSScreen.main returns the screen with keyboard focus (key window), not the primary display with the menu bar. This caused items without an explicit display to migrate to the wrong screen on display change events. Use CGMainDisplayID() which always returns the menu bar display.
1 parent ceb9c2f commit 41efff4

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Sources/RanmaAppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class RanmaAppDelegate: NSObject, NSApplicationDelegate {
5050
DisplayInfo(
5151
id: screen.displayID,
5252
name: screen.localizedName,
53-
isMain: screen == NSScreen.main
53+
isMain: screen.displayID == CGMainDisplayID()
5454
)
5555
}
5656
setDisplays(displays: displays)

0 commit comments

Comments
 (0)