Add ScreenCaptureAccess struct

This commit is contained in:
fcfangcc
2023-05-24 21:23:55 +08:00
parent 2784e317bd
commit d8b6ff1723
+20 -2
View File
@@ -1,8 +1,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
pub fn CGRequestScreenCaptureAccess() -> boolean_t;
pub fn CGPreflightScreenCaptureAccess() -> boolean_t;
fn CGRequestScreenCaptureAccess() -> boolean_t;
fn CGPreflightScreenCaptureAccess() -> boolean_t;
}