From 93defcd3a71bd161b217d7fe7b2255872d3cb1a6 Mon Sep 17 00:00:00 2001 From: lwouis Date: Mon, 3 Feb 2025 11:25:47 +0100 Subject: [PATCH] fix: stage manager no longer skews the thumbnails (closes #1731) --- src/api-wrappers/CGWindowID.swift | 2 +- src/api-wrappers/private-apis/SkyLight.framework.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api-wrappers/CGWindowID.swift b/src/api-wrappers/CGWindowID.swift index 46f3bfb4..206db046 100644 --- a/src/api-wrappers/CGWindowID.swift +++ b/src/api-wrappers/CGWindowID.swift @@ -18,7 +18,7 @@ extension CGWindowID { func screenshot() -> CGImage? { // we use CGSHWCaptureWindowList because it can screenshot minimized windows, which CGWindowListCreateImage can't var windowId_ = self - let list = CGSHWCaptureWindowList(CGS_CONNECTION, &windowId_, 1, [.ignoreGlobalClipShape, .bestResolution]).takeRetainedValue() as! [CGImage] + let list = CGSHWCaptureWindowList(CGS_CONNECTION, &windowId_, 1, [.ignoreGlobalClipShape, .bestResolution, .fullSize]).takeRetainedValue() as! [CGImage] return list.first // // CGWindowListCreateImage // return CGWindowListCreateImage(.null, .optionIncludingWindow, self, [.boundsIgnoreFraming, .bestResolution]) diff --git a/src/api-wrappers/private-apis/SkyLight.framework.swift b/src/api-wrappers/private-apis/SkyLight.framework.swift index 6245d243..4fd2a257 100644 --- a/src/api-wrappers/private-apis/SkyLight.framework.swift +++ b/src/api-wrappers/private-apis/SkyLight.framework.swift @@ -15,6 +15,8 @@ struct CGSWindowCaptureOptions: OptionSet { // on a retina display, 1px is spread on 4px, so nominalResolution is 1/4 of bestResolution static let nominalResolution = CGSWindowCaptureOptions(rawValue: 1 << 9) static let bestResolution = CGSWindowCaptureOptions(rawValue: 1 << 8) + // when Stage Manager is enabled, screenshots can become skewed. This param gets us full-size screenshots regardless + static let fullSize = CGSWindowCaptureOptions(rawValue: 1 << 19) } /// returns the connection to the WindowServer. This connection ID is required when calling other APIs