hex/src/permission_guide.rs
Kit Langton 7009a07025
Drop Input Monitoring; Accessibility covers the shortcut (t496)
* Drop Input Monitoring: Accessibility covers the shortcut taps (t496)

* Regenerate goldens without the Input Monitoring row (t496)

* Regenerate the permissions golden after merging dev (t496)
2026-10-28 13:59:57 -07:00

35 lines
1.1 KiB
Rust

//! The floating guide beside System Settings' Privacy & Security pane: it
//! opens the pane for one permission and offers Hex as a drag tile (or, for
//! a refused microphone, asks to switch Hex on), closing once it is granted.
use std::ffi::CStr;
use objc2::MainThreadMarker;
use crate::onboarding::PermissionKind;
unsafe extern "C" {
fn hex_show_permission_guide(permission: i32);
fn hex_permission_list_name(permission: i32) -> *const std::ffi::c_char;
}
const fn code(kind: PermissionKind) -> i32 {
match kind {
PermissionKind::Accessibility => 1,
PermissionKind::Microphone => 2,
PermissionKind::SystemAudio => 3,
PermissionKind::ScreenRecording => 4,
}
}
pub(crate) fn show(kind: PermissionKind) {
if MainThreadMarker::new().is_some() {
unsafe { hex_show_permission_guide(code(kind)) };
}
}
/// What System Settings calls the list: macOS 27 renamed Accessibility.
pub(crate) fn list_name(kind: PermissionKind) -> &'static str {
let name = unsafe { CStr::from_ptr(hex_permission_list_name(code(kind))) };
name.to_str().unwrap_or("Accessibility")
}