Repository: servo/core-foundation-rs (language: rust)

Issue:
ScreenCaptureAccess.preflight returns incorrect value for Intel based 64bit Mac
The function ScreenCaptureAccess.preflight [ [Ref](https://github.com/servo/core-foundation-rs/blob/e5162be4fa50c9f7f2f41f1d310eb49268c4e88e/core-graphics/src/access.rs#L17) ] returns incorrectly for Intel based 64 bit Macs.

On further inspection, the reason for this is that the external method `CGPreflightScreenCaptureAccess` returns a value which is not 1 ( even if the permissions have been given ). 
From my research, I've found that it returns a number whose lowest 8 bits are 0. So something like the following should work

<img width="609" alt="image" src="https://github.com/servo/core-foundation-rs/assets/20909078/4e448c9e-9797-4f0d-8d20-168316966bda">

That's what I'm doing in my fork [here](https://github.com/Pranav2612000/core-foundation-rs)

This is working good enough for me. What do you think about this approach? Does it make sense? I'm open to submitting a PR, or if you have a better solution in mind, I'll love to implement it.


Discussion / hints:
The correct way to work with external booleans is always to compare them against `NO` / `0`. So rather, you should use `!= 0`
Yup @madsmtm . That was what I tried first, but I observed that `CGPreflightScreenCaptureAccess` returns a non zero value ( the last 8 bits of which are 0 ) if screen capture permissions are not present. So the function would always return true, which is not the correct behaviour.

Is it possible that it's something to do with Boolean being 1 byte by int32 being 4 bytes? Because the last 8 bits of the returned value are always 0000 0000 or 0000 0001
Oh... Actually, you're right, the issue is that the definition in Rust is using `boolean_t` instead of `bool` :/
Yup. Thank you @madsmtm 
What do you think the next steps should be here? Happy to submit a PR
Can't answer that, not a maintainer here, sorry
Please submit a PR

Fix patch:
diff --git a/core-graphics/src/access.rs b/core-graphics/src/access.rs
index cd51acb0..014ff31a 100644
--- a/core-graphics/src/access.rs
+++ b/core-graphics/src/access.rs
@@ -1,5 +1,3 @@
-pub use crate::base::boolean_t;
-
 #[derive(Default)]
 pub struct ScreenCaptureAccess;
 
@@ -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;
 }


Test patch: