Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7cad2fc2f | ||
|
|
69e1a7fccb | ||
|
|
e22bcb99c4 |
@@ -21,6 +21,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
runOCRSelfTest()
|
runOCRSelfTest()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Single instance: stale copies keep their own hotkey + overlays alive
|
||||||
|
// after app updates and eat clicks meant for the new instance.
|
||||||
|
let myPid = ProcessInfo.processInfo.processIdentifier
|
||||||
|
let others = NSRunningApplication.runningApplications(withBundleIdentifier: "dev.tzgyn.kapture")
|
||||||
|
.filter { $0.processIdentifier != myPid }
|
||||||
|
if !others.isEmpty {
|
||||||
|
CaptureController.log("launch: other Kapture instances pids=\(others.map { String($0.processIdentifier) }.joined(separator: ",")) — terminating them")
|
||||||
|
for other in others {
|
||||||
|
other.forceTerminate()
|
||||||
|
}
|
||||||
|
}
|
||||||
HotkeyManager.shared.onTrigger = { CaptureController.shared.begin() }
|
HotkeyManager.shared.onTrigger = { CaptureController.shared.begin() }
|
||||||
HotkeyManager.shared.register()
|
HotkeyManager.shared.register()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,12 +61,15 @@ final class CaptureController: NSObject {
|
|||||||
}
|
}
|
||||||
isSelecting = true
|
isSelecting = true
|
||||||
previousApp = NSWorkspace.shared.frontmostApplication
|
previousApp = NSWorkspace.shared.frontmostApplication
|
||||||
// Force activation: cooperative NSApp.activate() can silently fail for
|
// Activation is ASYNC: isActive only flips on a later runloop tick
|
||||||
// LSUIElement apps, leaving the app inactive — then clicks on the
|
// (verified on macOS 26). Show overlays only once active, otherwise
|
||||||
// overlays pass through to the windows below.
|
// the first click can pass through to the windows below.
|
||||||
NSApp.activate(ignoringOtherApps: true)
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
CaptureController.log("begin: creating overlays for \(NSScreen.screens.count) screens")
|
CaptureController.log("begin: activate issued, active=\(NSApp.isActive)")
|
||||||
overlays = NSScreen.screens.map { screen in
|
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) },
|
||||||
@@ -74,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
@@ -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.2</string>
|
<string>1.6.5</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>62</string>
|
<string>65</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user