Skip to content

Commit 60bb173

Browse files
committed
v1.0.2: first-run window on primary screen + clean click feedback
- FirstRunWindow now centers on NSScreen.screens.first (primary display with the menu bar) instead of NSWindow.center(), which would land it on whichever screen has the key window — wrong on multi-monitor setups with a fullscreen secondary display. - ControlItem fires its action on leftMouseDown rather than leftMouseUp, so the wide push state ends before macOS draws the menu bar click highlight. Eliminates the translucent rectangle that was visible during click toggles.
1 parent edfea78 commit 60bb173

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

Resources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleVersion</key>
1010
<string>1</string>
1111
<key>CFBundleShortVersionString</key>
12-
<string>1.0.1</string>
12+
<string>1.0.2</string>
1313
<key>CFBundleIconFile</key>
1414
<string>AppIcon</string>
1515
<key>LSUIElement</key>

Sources/Veil/App/FirstRunWindow.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,20 @@ final class FirstRunWindow {
3030
w.styleMask = [.titled, .closable]
3131
w.isReleasedWhenClosed = false
3232
w.setContentSize(NSSize(width: 440, height: 340))
33-
w.center()
33+
// NSScreen.screens.first is the primary display (the one with the
34+
// menu bar); NSScreen.main follows the key window which on a
35+
// multi-monitor setup with a fullscreen app might land elsewhere.
36+
let screen = NSScreen.screens.first ?? NSScreen.main
37+
if let visible = screen?.visibleFrame {
38+
let size = w.frame.size
39+
let origin = NSPoint(
40+
x: visible.midX - size.width / 2,
41+
y: visible.midY - size.height / 2
42+
)
43+
w.setFrameOrigin(origin)
44+
} else {
45+
w.center()
46+
}
3447
window = w
3548
}
3649
NSApp.activate(ignoringOtherApps: true)

Sources/Veil/MenuBar/ControlItem.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@ final class ControlItem: NSObject {
7070
button.imagePosition = .imageOnly
7171
button.target = self
7272
button.action = #selector(clicked)
73-
button.sendAction(on: [.leftMouseUp, .rightMouseUp])
73+
button.sendAction(on: [.leftMouseDown, .rightMouseUp])
74+
// Suppress the button's bezel + highlight. Without this, when the
75+
// button is in its wide push state, the click/hover highlight
76+
// renders as a 280px translucent bar across the menu bar.
77+
button.isBordered = false
78+
if let cell = button.cell as? NSButtonCell {
79+
cell.highlightsBy = []
80+
cell.isBordered = false
81+
cell.bezelStyle = .inline
82+
}
7483
// Image is set by applyState.
7584
}
7685

@@ -121,7 +130,7 @@ final class ControlItem: NSObject {
121130
case .showItems:
122131
statusItem.isVisible = true
123132
statusItem.length = NSStatusItem.variableLength
124-
statusItem.button?.image = NSImage(systemSymbolName: icon.shownSymbol, accessibilityDescription: "Veil")
133+
statusItem.button?.image = NSImage(systemSymbolName: icon.shownSymbol, accessibilityDescription: "Hide items")
125134
resizeWindow(to: 26)
126135
}
127136
}

0 commit comments

Comments
 (0)