summaryrefslogtreecommitdiffstats
path: root/third_party/rust/core-graphics/src/access.rs
blob: 4e852c85ae842d8165f0fa05fafbabcbf3d2c670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub use base::boolean_t;

#[derive(Default)]
pub struct ScreenCaptureAccess;

impl ScreenCaptureAccess {
    /// If current app not in list, will open window.
    /// Return the same result as preflight.
    #[inline]
    pub fn request(&self) -> bool {
        unsafe { CGRequestScreenCaptureAccess() == 1 }
    }

    /// Return true if has access
    #[inline]
    pub fn preflight(&self) -> bool {
        unsafe { CGPreflightScreenCaptureAccess() == 1 }
    }
}

#[link(name = "CoreGraphics", kind = "framework")]
extern "C" {
    // Screen Capture Access
    fn CGRequestScreenCaptureAccess() -> boolean_t;
    fn CGPreflightScreenCaptureAccess() -> boolean_t;
}