From 78e53517e7c7a4a4659b1b638a68bdd4f40b233e Mon Sep 17 00:00:00 2001 From: Yury Date: Fri, 6 Dec 2024 10:13:20 +0300 Subject: [PATCH] screen capture macos 15.2 api --- cidre/src/sc/screenshot_manager.rs | 20 ++++++++++++++++++++ cidre/src/sc/stream.rs | 15 +++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/cidre/src/sc/screenshot_manager.rs b/cidre/src/sc/screenshot_manager.rs index 2d96f850..6da1ff50 100644 --- a/cidre/src/sc/screenshot_manager.rs +++ b/cidre/src/sc/screenshot_manager.rs @@ -54,6 +54,26 @@ impl ScreenshotManager { Self::capture_image_ch(filter, cfg, Some(&mut block)); future.await } + + /// Returns an image containing the contents of the rectangle in points, specified in display space + #[cfg(feature = "blocks")] + #[objc::msg_send(captureImageInRect:completionHandler:)] + #[api::available(macos = 15.2)] + pub fn capture_image_in_rect_ch( + rect: cg::Rect, + handler: Option<&mut blocks::ResultCompletionHandler>, + ); + + /// Returns an image containing the contents of the rectangle in points, specified in display space + #[cfg(all(feature = "blocks", feature = "async"))] + #[api::available(macos = 15.2)] + pub async fn capture_image_in_rect( + rect: cg::Rect, + ) -> Result, arc::R> { + let (future, mut block) = blocks::result(); + Self::capture_image_in_rect_ch(rect, Some(&mut block)); + future.await + } } #[link(name = "sc", kind = "static")] diff --git a/cidre/src/sc/stream.rs b/cidre/src/sc/stream.rs index 80246a34..3a3ef660 100644 --- a/cidre/src/sc/stream.rs +++ b/cidre/src/sc/stream.rs @@ -544,6 +544,21 @@ impl ContentFilter { #[objc::msg_send(setIncludeMenuBar:)] #[api::available(macos = 14.2)] pub fn set_include_menu_bar(&mut self, val: bool); + + /// sc::Displays that are included in the content filter + #[objc::msg_send(includedDisplays)] + #[api::available(macos = 15.2)] + pub fn included_displays(&self) -> arc::R>; + + /// Applications that are included in the content filter + #[objc::msg_send(includedApplications)] + #[api::available(macos = 15.2)] + pub fn included_apps(&self) -> arc::R>; + + /// Windows that are included in the content filter + #[objc::msg_send(includedWindows)] + #[api::available(macos = 15.2)] + pub fn included_windows(&self) -> arc::R>; } define_obj_type!(