screencapturekit/stream/configuration/
captured_elements.rs

1//! Captured elements configuration
2//!
3//! Methods for configuring which elements are included in the capture
4//! (cursor, shadows, etc.).
5
6use super::internal::SCStreamConfiguration;
7
8impl SCStreamConfiguration {
9    /// Show or hide the cursor in captured frames
10    ///
11    /// # Examples
12    ///
13    /// ```
14    /// use screencapturekit::prelude::*;
15    ///
16    /// let mut config = SCStreamConfiguration::default();
17    /// config.set_shows_cursor(true);
18    /// assert!(config.get_shows_cursor());
19    /// ```
20    pub fn set_shows_cursor(&mut self, shows_cursor: bool) {
21        unsafe {
22            crate::ffi::sc_stream_configuration_set_shows_cursor(self.as_ptr(), shows_cursor);
23        }
24    }
25
26    /// Check if cursor is shown in capture
27    pub fn get_shows_cursor(&self) -> bool {
28        unsafe { crate::ffi::sc_stream_configuration_get_shows_cursor(self.as_ptr()) }
29    }
30
31    /// Capture only window shadows (macOS 14.0+)
32    ///
33    /// When set to `true`, the stream captures only the shadows of windows,
34    /// not the actual window content. This is useful for creating transparency
35    /// or blur effects in compositing applications.
36    ///
37    /// # Availability
38    /// macOS 14.0+. On earlier versions, this setting has no effect.
39    ///
40    /// # Examples
41    /// ```
42    /// use screencapturekit::prelude::*;
43    ///
44    /// let mut config = SCStreamConfiguration::default();
45    /// config.set_width(1920);
46    /// config.set_height(1080);
47    /// config.set_captures_shadows_only(true); // Only capture shadows
48    /// ```
49    pub fn set_captures_shadows_only(&mut self, captures_shadows_only: bool) {
50        unsafe {
51            crate::ffi::sc_stream_configuration_set_captures_shadows_only(
52                self.as_ptr(),
53                captures_shadows_only,
54            );
55        }
56    }
57
58    /// Get whether only window shadows are captured (macOS 14.0+).
59    pub fn get_captures_shadows_only(&self) -> bool {
60        unsafe { crate::ffi::sc_stream_configuration_get_captures_shadows_only(self.as_ptr()) }
61    }
62}