mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Add Window::set_content_protected on macOS and Windows (#2525)
* Add `Window::set_content_protect` on macOS and Windows * Update window.rs * Add builder variant * fix import * fix argument type * fix import * fix always visible window on Windows * update docs
This commit is contained in:
@@ -45,7 +45,8 @@ use objc2::{declare_class, msg_send, msg_send_id, sel, ClassType};
|
||||
use super::appkit::{
|
||||
NSApp, NSAppKitVersion, NSAppearance, NSApplicationPresentationOptions, NSBackingStoreType,
|
||||
NSColor, NSCursor, NSFilenamesPboardType, NSRequestUserAttentionType, NSResponder, NSScreen,
|
||||
NSWindow, NSWindowButton, NSWindowLevel, NSWindowStyleMask, NSWindowTitleVisibility,
|
||||
NSWindow, NSWindowButton, NSWindowLevel, NSWindowSharingType, NSWindowStyleMask,
|
||||
NSWindowTitleVisibility,
|
||||
};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
@@ -305,6 +306,10 @@ impl WinitWindow {
|
||||
this.setTitle(&NSString::from_str(&attrs.title));
|
||||
this.setAcceptsMouseMovedEvents(true);
|
||||
|
||||
if attrs.content_protected {
|
||||
this.setSharingType(NSWindowSharingType::NSWindowSharingNone);
|
||||
}
|
||||
|
||||
if pl_attrs.titlebar_transparent {
|
||||
this.setTitlebarAppearsTransparent(true);
|
||||
}
|
||||
@@ -1123,6 +1128,14 @@ impl WinitWindow {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_content_protected(&self, protected: bool) {
|
||||
self.setSharingType(if protected {
|
||||
NSWindowSharingType::NSWindowSharingNone
|
||||
} else {
|
||||
NSWindowSharingType::NSWindowSharingReadOnly
|
||||
})
|
||||
}
|
||||
|
||||
pub fn title(&self) -> String {
|
||||
self.title_().to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user