From 457e303152d6b83a5c37de3900a23d008a4e2cd9 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 9 Sep 2026 11:00:44 +0800 Subject: [PATCH] Force app activation on capture; log to /tmp for durable diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cooperative NSApp.activate() can silently fail for LSUIElement apps, leaving the app inactive so overlay clicks pass through to windows below. Force activation with ignoringOtherApps on all OS versions. Session logs now also append to /tmp/kapture-debug.log so they survive relaunches, and the first window-scan result is always logged. 💘 Generated with Crush Assisted-by: Crush:deepseek-v4-flash-0731 --- Sources/Kapture/CaptureController.swift | 11 ++++++----- build-app.sh | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/Kapture/CaptureController.swift b/Sources/Kapture/CaptureController.swift index a584dec..c89a8ff 100644 --- a/Sources/Kapture/CaptureController.swift +++ b/Sources/Kapture/CaptureController.swift @@ -61,11 +61,11 @@ final class CaptureController: NSObject { } isSelecting = true previousApp = NSWorkspace.shared.frontmostApplication - if #available(macOS 14.0, *) { - NSApp.activate() - } else { - NSApp.activate(ignoringOtherApps: true) - } + // Force activation: cooperative NSApp.activate() can silently fail for + // LSUIElement apps, leaving the app inactive — then clicks on the + // overlays pass through to the windows below. + NSApp.activate(ignoringOtherApps: true) + CaptureController.log("begin: creating overlays for \(NSScreen.screens.count) screens") overlays = NSScreen.screens.map { screen in OverlayWindow( screen: screen, @@ -76,6 +76,7 @@ final class CaptureController: NSObject { } overlays.forEach { $0.makeKeyAndOrderFront(nil) } overlayIDs = overlays.map { $0.windowNumber } + CaptureController.log("begin: \(overlays.count) overlays, ids=\(overlayIDs), active=\(NSApp.isActive)") } /// A window was picked from hover — capture it with rounded corners. diff --git a/build-app.sh b/build-app.sh index 3efc363..e6f7342 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.6.1 + 1.6.2 CFBundleVersion - 61 + 62 LSUIElement NSHighResolutionCapable