nashaofu / xcap

XCap is a cross-platform screen capture library written in Rust. It supports Linux (X11, Wayland), MacOS, and Windows. XCap supports screenshot and video recording (to be implemented).
https://docs.rs/xcap
Apache License 2.0
459 stars 55 forks source link

Macos screenshot gets background only #144

Closed itsmhe closed 3 days ago

itsmhe commented 3 weeks ago

Hi there,

im using your xcap in a tauri application and when i take a screenshot with this library of the whole screen i can only see the application itself and the desktop.

Even when i run the code from the readme.md file to get the screenshots, i only get the background with no applications on it.

I suspect this is some kind of privacy or permissions problem, but I do not know where to start.

nashaofu commented 3 weeks ago

https://github.com/nashaofu/xcap/issues/123

nashaofu commented 3 weeks ago
use core_graphics::access::ScreenCaptureAccess;

pub fn has_permission() -> bool {
    ScreenCaptureAccess::default().preflight()
}

pub fn request_permission() -> bool {
    ScreenCaptureAccess::default().request()
}
itsmhe commented 3 days ago

Code signing fixed it for me. Thanks for the help.