Files
oak-gpui/crates/gpui_macos/src/window_appearance.rs
T
Mike-Solar af5482d774 style: cargo fmt with the workspace tab policy (hard_tabs)
Whitespace only; the fork has no own rustfmt.toml so the Oak root
policy applies.
2026-08-11 23:06:13 +08:00

36 lines
938 B
Rust

use cocoa::{
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
base::id,
foundation::NSString,
};
use gpui::WindowAppearance;
use objc::{msg_send, sel, sel_impl};
use std::ffi::CStr;
pub(crate) unsafe fn window_appearance_from_native(appearance: id) -> WindowAppearance {
let name: id = msg_send![appearance, name];
unsafe {
if name == NSAppearanceNameVibrantLight {
WindowAppearance::VibrantLight
} else if name == NSAppearanceNameVibrantDark {
WindowAppearance::VibrantDark
} else if name == NSAppearanceNameAqua {
WindowAppearance::Light
} else if name == NSAppearanceNameDarkAqua {
WindowAppearance::Dark
} else {
println!(
"unknown appearance: {:?}",
CStr::from_ptr(name.UTF8String())
);
WindowAppearance::Light
}
}
}
#[link(name = "AppKit", kind = "framework")]
unsafe extern "C" {
pub static NSAppearanceNameAqua: id;
pub static NSAppearanceNameDarkAqua: id;
}