Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef44ef7ac6 | ||
|
|
715bb28c1b |
@@ -262,9 +262,21 @@ final class CaptureController: NSObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// System dialogs (permission prompts, System Settings) must always
|
||||||
|
/// receive their clicks even while we're selecting.
|
||||||
|
private func isSystemDialogFrontmost() -> Bool {
|
||||||
|
guard let front = NSWorkspace.shared.frontmostApplication else { return false }
|
||||||
|
let id = front.bundleIdentifier ?? ""
|
||||||
|
return id.hasPrefix("com.apple.security") || id.hasPrefix("com.apple.SystemSettings") || id == "com.apple.systempreferences"
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the event to pass through, or nil to consume it.
|
/// Returns the event to pass through, or nil to consume it.
|
||||||
func handleTap(_ type: CGEventType, _ event: CGEvent) -> CGEvent? {
|
func handleTap(_ type: CGEventType, _ event: CGEvent) -> CGEvent? {
|
||||||
guard isSelecting else { return event }
|
guard isSelecting else { return event }
|
||||||
|
if isSystemDialogFrontmost() {
|
||||||
|
CaptureController.log("tap: system dialog frontmost — passing through \(type)")
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
|
||||||
switch type {
|
switch type {
|
||||||
case .tapDisabledByUserInput, .tapDisabledByTimeout:
|
case .tapDisabledByUserInput, .tapDisabledByTimeout:
|
||||||
@@ -301,8 +313,11 @@ final class CaptureController: NSObject {
|
|||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
// Drag: grow the marquee
|
// Drag: grow the marquee — but only after real movement, so a
|
||||||
|
// click's micro-jitter keeps the hovered window eligible.
|
||||||
guard let start = marqueeStart else { return nil }
|
guard let start = marqueeStart else { return nil }
|
||||||
|
let distance = hypot(appKitPoint.x - start.x, appKitPoint.y - start.y)
|
||||||
|
guard distance >= 4 else { return nil }
|
||||||
let rect = NSRect(
|
let rect = NSRect(
|
||||||
x: min(start.x, appKitPoint.x),
|
x: min(start.x, appKitPoint.x),
|
||||||
y: min(start.y, appKitPoint.y),
|
y: min(start.y, appKitPoint.y),
|
||||||
@@ -443,28 +458,43 @@ final class ScreenCapture {
|
|||||||
let detected = Self.detectCornerRadius(of: result)
|
let detected = Self.detectCornerRadius(of: result)
|
||||||
let radius = min(max((detected.map { $0 * 1.23 + 2.6 }) ?? (10 * scaleX), 4), 40)
|
let radius = min(max((detected.map { $0 * 1.23 + 2.6 }) ?? (10 * scaleX), 4), 40)
|
||||||
CaptureController.log("corners: detected=\(detected.map { String(format: "%.1f", $0) } ?? "nil") using=\(Int(radius))px")
|
CaptureController.log("corners: detected=\(detected.map { String(format: "%.1f", $0) } ?? "nil") using=\(Int(radius))px")
|
||||||
|
// Anti-aliased gray mask: supersample 3x, downsample, then draw
|
||||||
|
// the image through it ONCE at 1x (no content resampling blur).
|
||||||
let ss = 3
|
let ss = 3
|
||||||
let W = result.width * ss, H = result.height * ss
|
let W = result.width * ss, H = result.height * ss
|
||||||
guard let hiCtx = CGContext(
|
guard let hiMask = CGContext(
|
||||||
data: nil, width: W, height: H,
|
data: nil, width: W, height: H,
|
||||||
bitsPerComponent: 8, bytesPerRow: 0,
|
bitsPerComponent: 8, bytesPerRow: 0,
|
||||||
space: CGColorSpaceCreateDeviceRGB(),
|
space: CGColorSpaceCreateDeviceGray(),
|
||||||
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
|
bitmapInfo: CGImageAlphaInfo.none.rawValue
|
||||||
) else { return result }
|
) else { return result }
|
||||||
hiCtx.addPath(CGPath(roundedRect: CGRect(x: 0, y: 0, width: W, height: H), cornerWidth: radius * CGFloat(ss), cornerHeight: radius * CGFloat(ss), transform: nil))
|
hiMask.setFillColor(CGColor(gray: 1, alpha: 1))
|
||||||
hiCtx.clip()
|
hiMask.fill(CGRect(x: 0, y: 0, width: W, height: H))
|
||||||
hiCtx.interpolationQuality = .high
|
hiMask.setFillColor(CGColor(gray: 0, alpha: 1))
|
||||||
hiCtx.draw(result, in: CGRect(x: 0, y: 0, width: W, height: H))
|
let cornerPath = CGMutablePath()
|
||||||
guard let hi = hiCtx.makeImage(),
|
cornerPath.addRect(CGRect(x: 0, y: 0, width: W, height: H))
|
||||||
let downCtx = CGContext(
|
cornerPath.addRoundedRect(in: CGRect(x: 0, y: 0, width: W, height: H), cornerWidth: radius * CGFloat(ss), cornerHeight: radius * CGFloat(ss), transform: .identity)
|
||||||
|
hiMask.addPath(cornerPath)
|
||||||
|
hiMask.fillPath(using: .evenOdd)
|
||||||
|
guard let hiMaskImg = hiMask.makeImage(),
|
||||||
|
let downMask = CGContext(
|
||||||
|
data: nil, width: result.width, height: result.height,
|
||||||
|
bitsPerComponent: 8, bytesPerRow: 0,
|
||||||
|
space: CGColorSpaceCreateDeviceGray(),
|
||||||
|
bitmapInfo: CGImageAlphaInfo.none.rawValue
|
||||||
|
) else { return result }
|
||||||
|
downMask.interpolationQuality = .high
|
||||||
|
downMask.draw(hiMaskImg, in: CGRect(x: 0, y: 0, width: result.width, height: result.height))
|
||||||
|
guard let mask1x = downMask.makeImage(),
|
||||||
|
let ctx = CGContext(
|
||||||
data: nil, width: result.width, height: result.height,
|
data: nil, width: result.width, height: result.height,
|
||||||
bitsPerComponent: 8, bytesPerRow: 0,
|
bitsPerComponent: 8, bytesPerRow: 0,
|
||||||
space: CGColorSpaceCreateDeviceRGB(),
|
space: CGColorSpaceCreateDeviceRGB(),
|
||||||
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
|
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
|
||||||
) else { return result }
|
) else { return result }
|
||||||
downCtx.interpolationQuality = .high
|
ctx.clip(to: CGRect(x: 0, y: 0, width: result.width, height: result.height), mask: mask1x)
|
||||||
downCtx.draw(hi, in: CGRect(x: 0, y: 0, width: result.width, height: result.height))
|
ctx.draw(result, in: CGRect(x: 0, y: 0, width: result.width, height: result.height))
|
||||||
if let masked = downCtx.makeImage() {
|
if let masked = ctx.makeImage() {
|
||||||
result = masked
|
result = masked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,23 @@ final class OverlayView: NSView {
|
|||||||
NSColor.black.withAlphaComponent(0.35).setFill()
|
NSColor.black.withAlphaComponent(0.35).setFill()
|
||||||
NSBezierPath(rect: bounds).fill()
|
NSBezierPath(rect: bounds).fill()
|
||||||
|
|
||||||
|
// Esc hint — the only way out once clicks are consumed by the tap.
|
||||||
|
let hint = "Drag to select · hover + click a window to capture it · Esc to cancel"
|
||||||
|
let hintAttrs: [NSAttributedString.Key: Any] = [
|
||||||
|
.font: NSFont.monospacedSystemFont(ofSize: 12, weight: .medium),
|
||||||
|
.foregroundColor: NSColor.white.withAlphaComponent(0.85),
|
||||||
|
]
|
||||||
|
let hintSize = hint.size(withAttributes: hintAttrs)
|
||||||
|
let hintRect = NSRect(
|
||||||
|
x: (bounds.width - hintSize.width) / 2 - 10,
|
||||||
|
y: bounds.height - 46,
|
||||||
|
width: hintSize.width + 20,
|
||||||
|
height: hintSize.height + 12
|
||||||
|
)
|
||||||
|
NSColor.black.withAlphaComponent(0.65).setFill()
|
||||||
|
NSBezierPath(roundedRect: hintRect, xRadius: 8, yRadius: 8).fill()
|
||||||
|
hint.draw(at: NSPoint(x: hintRect.minX + 10, y: hintRect.minY + 6), withAttributes: hintAttrs)
|
||||||
|
|
||||||
guard let controller else { return }
|
guard let controller else { return }
|
||||||
|
|
||||||
// Highlight the hovered window (rounded, like real window corners)
|
// Highlight the hovered window (rounded, like real window 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.8.5</string>
|
<string>1.8.7</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>85</string>
|
<string>87</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user