plat/apple_mac_screen.rs (Apple)#
Source: lib/plat/apple_mac_screen.rs
apple_mac_screen -- (screen.rs) macOS: the colour pick and pictures of the screen
pick_available() -> bool NSColorSampler is there (macOS 10.15 and later)
pick_start(test) -> Result the system's loupe (NSColorSampler): the user clicks a pixel
anywhere, Esc cancels; the colour comes in sRGB. It needs no
right: the system takes the picture, the app gets one colour.
A test point (pick_test_point) answers the pixel there from a
picture of the screen instead -- which needs the right below
capture_available() -> bool true (the right is asked when taking)
capture_start(rect) -> Result a picture of rect (desktop px; None: every monitor together)
mac_screen_access() -> bool (tests) the process may record the screen
Pictures need the user's "Screen & System Audio Recording" right (TCC) for the program (the
app, or the terminal that started it): without it capture_start asks the system once
(CGRequestScreenCaptureAccess shows its dialog, which leads to the System Settings) and answers
Denied; the right counts from the next start of the program. macOS 15.2 and later take the
picture through ScreenCaptureKit (SCScreenshotManager captureImageInRect:, the answer on a queue
of the system); before, CGWindowListCreateImage (looked up at run time: newer SDKs no longer
offer it). Desktop px are points times the screen's scale from the top left of the primary
screen (monitors_os): a rectangle becomes points by the scale of the monitor at its corner. The
picture is drawn into B, G, R, x rows in sRGB (colours match what the app drew in sRGB, up to
the conversion through the display's profile).
fn mac_screen_access() -> bool(tests) the process may record the screen (asks nothing)