diff --git a/crates/cli/build.rs b/crates/cli/build.rs index f07d12546a58254edafcb7b269b241785f427bb5..d41647c6963d7e198710664ec85ed22f4695dfa5 100644 --- a/crates/cli/build.rs +++ b/crates/cli/build.rs @@ -7,8 +7,6 @@ fn main() { if cfg!(target_os = "macos") { println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7"); - // Weakly link ScreenCaptureKit to ensure can be used on macOS 10.15+. - println!("cargo:rustc-link-arg=-Wl,-weak_framework,ScreenCaptureKit"); } // Populate git sha environment variable if git is available diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 9c2b0bafa998eb7f012057362e524eabcdb78346..e30a7648a8a74bdb4d6ff611fe83de0422dbee87 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -77,8 +77,8 @@ mod macos { fn generate_dispatch_bindings() { println!("cargo:rustc-link-lib=framework=System"); - println!("cargo:rustc-link-lib=framework=ScreenCaptureKit"); - println!("cargo:rerun-if-changed=src/platform/mac/dispatch.h"); + // weak link to support Catalina + println!("cargo:rustc-link-arg=-Wl,-weak_framework,ScreenCaptureKit"); let bindings = bindgen::Builder::default() .header("src/platform/mac/dispatch.h") diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index 0bda71369e48eea139930094f6ed21bbd87d9b84..759e5462d0b9a369ce68d192c4f03fd3c440a36f 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -2,7 +2,7 @@ use super::{ BoolExt, attributed_string::{NSAttributedString, NSMutableAttributedString}, events::key_to_native, - renderer, screen_capture, + is_macos_version_at_least, renderer, screen_capture, }; use crate::{ Action, AnyWindowHandle, BackgroundExecutor, ClipboardEntry, ClipboardItem, ClipboardString, @@ -22,8 +22,8 @@ use cocoa::{ }, base::{BOOL, NO, YES, id, nil, selector}, foundation::{ - NSArray, NSAutoreleasePool, NSBundle, NSData, NSInteger, NSProcessInfo, NSRange, NSString, - NSUInteger, NSURL, + NSArray, NSAutoreleasePool, NSBundle, NSData, NSInteger, NSOperatingSystemVersion, + NSProcessInfo, NSRange, NSString, NSUInteger, NSURL, }, }; use core_foundation::{ @@ -553,7 +553,8 @@ impl Platform for MacPlatform { } fn is_screen_capture_supported(&self) -> bool { - true + let min_version = NSOperatingSystemVersion::new(12, 3, 0); + is_macos_version_at_least(min_version) } fn screen_capture_sources( diff --git a/crates/gpui/src/platform/mac/screen_capture.rs b/crates/gpui/src/platform/mac/screen_capture.rs index 8e9fc3d3f9f7e14a750544ada7febb8674d2cb78..ac2503bb20e437837a536a60d584c024029eb402 100644 --- a/crates/gpui/src/platform/mac/screen_capture.rs +++ b/crates/gpui/src/platform/mac/screen_capture.rs @@ -37,9 +37,6 @@ pub struct MacScreenCaptureStream { sc_stream_output: id, } -#[link(name = "ScreenCaptureKit", kind = "framework")] -unsafe extern "C" {} - static mut DELEGATE_CLASS: *const Class = ptr::null(); static mut OUTPUT_CLASS: *const Class = ptr::null(); const FRAME_CALLBACK_IVAR: &str = "frame_callback"; diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 532856d890032c10dfd999545b6dab48bae55c02..26a62aeadfd0b54d417bdff13d786b5baf4e5ccb 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1568,7 +1568,7 @@ extern "C" fn window_will_exit_fullscreen(this: &Object, _: Sel, _: id) { } } -fn is_macos_version_at_least(version: NSOperatingSystemVersion) -> bool { +pub(crate) fn is_macos_version_at_least(version: NSOperatingSystemVersion) -> bool { unsafe { NSProcessInfo::processInfo(nil).isOperatingSystemAtLeastVersion(version) } }