Skip to content

Commit

Permalink
screen capture macos 15.2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 6, 2024
1 parent 999d83e commit 78e5351
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cidre/src/sc/screenshot_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<cg::Image>>,
);

/// 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<cg::Image>, arc::R<ns::Error>> {
let (future, mut block) = blocks::result();
Self::capture_image_in_rect_ch(rect, Some(&mut block));
future.await
}
}

#[link(name = "sc", kind = "static")]
Expand Down
15 changes: 15 additions & 0 deletions cidre/src/sc/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ns::Array<sc::Display>>;

/// Applications that are included in the content filter
#[objc::msg_send(includedApplications)]
#[api::available(macos = 15.2)]
pub fn included_apps(&self) -> arc::R<ns::Array<sc::RunningApp>>;

/// Windows that are included in the content filter
#[objc::msg_send(includedWindows)]
#[api::available(macos = 15.2)]
pub fn included_windows(&self) -> arc::R<ns::Array<sc::Window>>;
}

define_obj_type!(
Expand Down

0 comments on commit 78e5351

Please # to comment.