Skip to content

Commit

Permalink
Correct screen capture access return values. (#698)
Browse files Browse the repository at this point in the history
Both `CGRequestScreenCaptureAccess` and `CGPreflightScreenCaptureAccess`
return `bool`, not `boolean_t`.

Fixes #677.
Replaces #678.
  • Loading branch information
waywardmonkeys authored Aug 12, 2024
1 parent b10b72c commit e513e99
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core-graphics/src/access.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub use crate::base::boolean_t;

#[derive(Default)]
pub struct ScreenCaptureAccess;

Expand All @@ -8,19 +6,19 @@ impl ScreenCaptureAccess {
/// Return the same result as preflight.
#[inline]
pub fn request(&self) -> bool {
unsafe { CGRequestScreenCaptureAccess() == 1 }
unsafe { CGRequestScreenCaptureAccess() }
}

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

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

0 comments on commit e513e99

Please sign in to comment.