numist / Switch

A window-based context switcher for the Mac
157 stars 17 forks source link

Explore adopting ScreenCaptureKit #140

Open numist opened 1 year ago

numist commented 1 year ago

ScreenCaptureKit is the new blessèd way to capture screen contents (instead of CGWindowListCreateImage) and includes some useful features like automatically handling image resizing on the gpu.

Unfortunately the only way to manifest an SCWindow is from an instance of SCShareableContent, which affects all of Switch's window list and content code. Also the API is async which is cool but means even more rearchitecting.

let content = try await SCShareableContent.excludingDesktopWindows(false, onscreenWindowsOnly: true)
numist commented 1 year ago

Now that I've had some time to noodle on this, I think that WindowInfo needs to become a protocol, as should the interface that provides window content images. To aid in transition (and testing) it might be worth also protocolizing the window list publisher types (and making them actors). This way WindowInfoGroup can conform to WindowInfo/WindowContents and the existing struct WindowInfo can stick around as a value type used by both the unit tests and the CG window list publisher.

numist commented 1 year ago

lol I guess this just got more important. sigh.

Screenshot 2023-07-18 at 2 24 59 PM