use objc2::rc::{Id, Shared}; use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use sdl2::video::Window; #[cfg(target_os = "macos")] mod appkit; pub trait Tap { fn tap(self) -> Self; } impl Tap for Window { fn tap(self) -> Self { tap(&self); self } } fn tap(window: &Window) { match window.raw_window_handle() { #[cfg(target_os = "macos")] RawWindowHandle::AppKit(handle) => { use crate::appkit::{NSWindowButton, NSWindowStyleMask, NSWindowTitleVisibility}; let ns_window: Option> = unsafe { Id::new(handle.ns_window as *mut appkit::NSWindow) }; let ns_window = ns_window.expect("ns_window should not be null"); { let mut mask = ns_window.style_mask(); mask |= NSWindowStyleMask::FULL_SIZE_CONTENT_VIEW; ns_window.set_style_mask(mask); } ns_window.set_title_visibility(NSWindowTitleVisibility::Hidden); ns_window.set_titlebar_appears_transparent(true); for titlebar_button in [ NSWindowButton::Close, NSWindowButton::Miniaturize, NSWindowButton::Zoom, #[allow(deprecated)] NSWindowButton::FullScreen, ] { if let Some(button) = ns_window.standard_window_button(titlebar_button) { button.set_hidden(true); } } } _ => {} } }