Compare commits

...
1 Commits
Author SHA1 Message Date
TZGyn 69e1a7fccb Show overlays only after activation completes
The local probe confirmed activation is asynchronous on macOS 26:
isActive flips on a later runloop tick, so overlays shown in the same
tick as activate() belong to a still-inactive app and misses clicks.
Delay overlay creation by a tick and log the activation state at show
time.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4-flash-0731
2026-09-09 11:51:13 +08:00
2 changed files with 21 additions and 16 deletions
+13 -8
View File
@@ -61,11 +61,15 @@ final class CaptureController: NSObject {
} }
isSelecting = true isSelecting = true
previousApp = NSWorkspace.shared.frontmostApplication previousApp = NSWorkspace.shared.frontmostApplication
// Force activation and log whether it stuck — inactive apps don't // Activation is ASYNC: isActive only flips on a later runloop tick
// receive overlay clicks. // (verified on macOS 26). Show overlays only once active, otherwise
let activated = NSApp.activate(ignoringOtherApps: true) // the first click can pass through to the windows below.
CaptureController.log("begin: activate(ignoringOtherApps)=\(activated) active=\(NSApp.isActive)") NSApp.activate(ignoringOtherApps: true)
overlays = NSScreen.screens.map { screen in CaptureController.log("begin: activate issued, active=\(NSApp.isActive)")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
guard let self, self.isSelecting else { return }
CaptureController.log("begin: active=\(NSApp.isActive) — showing overlays")
self.overlays = NSScreen.screens.map { screen in
OverlayWindow( OverlayWindow(
screen: screen, screen: screen,
onComplete: { [weak self] rect in self?.finishSelection(rect) }, onComplete: { [weak self] rect in self?.finishSelection(rect) },
@@ -73,9 +77,10 @@ final class CaptureController: NSObject {
onWindowPick: { [weak self] rect in self?.finishWindowPick(rect) } onWindowPick: { [weak self] rect in self?.finishWindowPick(rect) }
) )
} }
overlays.forEach { $0.makeKeyAndOrderFront(nil) } self.overlays.forEach { $0.makeKeyAndOrderFront(nil) }
overlayIDs = overlays.map { $0.windowNumber } self.overlayIDs = self.overlays.map { $0.windowNumber }
CaptureController.log("begin: \(overlays.count) overlays, ids=\(overlayIDs), active=\(NSApp.isActive)") CaptureController.log("begin: \(self.overlays.count) overlays, ids=\(self.overlayIDs), active=\(NSApp.isActive)")
}
} }
/// A window was picked from hover — capture it with rounded corners. /// A window was picked from hover — capture it with rounded corners.
+2 -2
View File
@@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST'
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>Icon</string> <string>Icon</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.6.3</string> <string>1.6.4</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>63</string> <string>64</string>
<key>LSUIElement</key> <key>LSUIElement</key>
<true/> <true/>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>