From 1327b61e2be8b6927b4eb098121cd611c234b5d8 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 12 Aug 2026 16:37:53 +0800 Subject: [PATCH] Request capture pixels from the selection screen's backing scale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SCDisplay.width is in points, not pixels: the previous fix sent point counts to SCStreamConfiguration, producing blurry main-screen captures and failed secondary-screen captures. Multiply by the backing scale factor of the screen containing the selection (defaulting to 1x, never forcing 2x). 💘 Generated with Crush Assisted-by: Crush:deepseek-v4-flash-0731 --- Sources/Kapture/CaptureController.swift | 13 +++++++++---- build-app.sh | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/Kapture/CaptureController.swift b/Sources/Kapture/CaptureController.swift index 0da1e55..de16215 100644 --- a/Sources/Kapture/CaptureController.swift +++ b/Sources/Kapture/CaptureController.swift @@ -141,10 +141,15 @@ final class ScreenCapture { let excluded = content.windows.filter { excludedSet.contains($0.windowID) } let filter = SCContentFilter(display: display, excludingWindows: excluded) let config = SCStreamConfiguration() - // display.width/height are pixels; request the display's full - // native resolution so ScreenCaptureKit gives us every pixel. - config.width = Int(display.width) - config.height = Int(display.height) + // SCDisplay.width/height are in POINTS; SCStreamConfiguration + // width/height are output PIXELS. Multiply by the backing scale + // of the screen containing the selection so retina displays are + // captured at full resolution and 1x displays stay 1x. + let backingScale = NSScreen.screens + .first(where: { $0.frame.contains(NSPoint(x: rect.midX, y: rect.midY)) })? + .backingScaleFactor ?? 1 + config.width = Int(CGFloat(display.width) * backingScale) + config.height = Int(CGFloat(display.height) * backingScale) config.showsCursor = true guard let image = try? await SCScreenshotManager.captureImage(contentFilter: filter, configuration: config) else { diff --git a/build-app.sh b/build-app.sh index 33c77dd..93a1f8a 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.1.4 + 1.1.5 CFBundleVersion - 14 + 15 LSUIElement NSHighResolutionCapable