2023-07-29 00:33:03 +02:00
|
|
|
use icrate::Foundation::{
|
2022-09-08 16:45:29 +02:00
|
|
|
CGFloat, NSArray, NSInteger, NSObject, NSPoint, NSRect, NSSize, NSString, NSUInteger,
|
|
|
|
|
};
|
2023-07-29 00:33:03 +02:00
|
|
|
use objc2::encode::{Encode, Encoding};
|
|
|
|
|
use objc2::rc::Id;
|
2022-09-08 16:45:29 +02:00
|
|
|
use objc2::runtime::Object;
|
2023-07-29 00:33:03 +02:00
|
|
|
use objc2::{extern_class, extern_methods, mutability, ClassType};
|
2022-09-02 18:46:18 +02:00
|
|
|
|
2023-07-13 06:52:34 +00:00
|
|
|
use super::{
|
|
|
|
|
NSButton, NSColor, NSEvent, NSPasteboardType, NSResponder, NSScreen, NSView, NSWindowTabGroup,
|
|
|
|
|
};
|
2022-09-02 18:46:18 +02:00
|
|
|
|
|
|
|
|
extern_class!(
|
2022-09-08 16:45:29 +02:00
|
|
|
/// Main-Thread-Only!
|
2022-09-02 18:46:18 +02:00
|
|
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
2023-07-29 00:33:03 +02:00
|
|
|
pub struct NSWindow;
|
2022-09-02 18:46:18 +02:00
|
|
|
|
|
|
|
|
unsafe impl ClassType for NSWindow {
|
|
|
|
|
#[inherits(NSObject)]
|
|
|
|
|
type Super = NSResponder;
|
2023-07-29 00:33:03 +02:00
|
|
|
type Mutability = mutability::InteriorMutable;
|
2022-09-02 18:46:18 +02:00
|
|
|
}
|
|
|
|
|
);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
|
|
|
|
// Documented as "Main Thread Only", but:
|
|
|
|
|
// > Thread safe in that you can create and manage them on a secondary thread.
|
|
|
|
|
// <https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaFundamentals/AddingBehaviortoaCocoaProgram/AddingBehaviorCocoa.html#//apple_ref/doc/uid/TP40002974-CH5-SW47>
|
|
|
|
|
// <https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-123364>
|
|
|
|
|
//
|
|
|
|
|
// So could in theory be `Send`, and perhaps also `Sync` - but we would like
|
|
|
|
|
// interior mutability on windows, since that's just much easier, and in that
|
|
|
|
|
// case, they can't be!
|
|
|
|
|
|
|
|
|
|
extern_methods!(
|
|
|
|
|
unsafe impl NSWindow {
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(frame)]
|
|
|
|
|
pub(crate) fn frame(&self) -> NSRect;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(backingScaleFactor)]
|
|
|
|
|
pub(crate) fn backingScaleFactor(&self) -> CGFloat;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(contentView)]
|
|
|
|
|
pub(crate) fn contentView(&self) -> Id<NSView>;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setContentView:)]
|
|
|
|
|
pub(crate) fn setContentView(&self, view: &NSView);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setInitialFirstResponder:)]
|
|
|
|
|
pub(crate) fn setInitialFirstResponder(&self, view: &NSView);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(makeFirstResponder:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
#[must_use]
|
2023-07-29 00:33:03 +02:00
|
|
|
pub(crate) fn makeFirstResponder(&self, responder: Option<&NSResponder>) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(contentRectForFrameRect:)]
|
|
|
|
|
pub(crate) fn contentRectForFrameRect(&self, windowFrame: NSRect) -> NSRect;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(screen)]
|
|
|
|
|
pub(crate) fn screen(&self) -> Option<Id<NSScreen>>;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setContentSize:)]
|
|
|
|
|
pub(crate) fn setContentSize(&self, contentSize: NSSize);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setFrameTopLeftPoint:)]
|
|
|
|
|
pub(crate) fn setFrameTopLeftPoint(&self, point: NSPoint);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setMinSize:)]
|
|
|
|
|
pub(crate) fn setMinSize(&self, minSize: NSSize);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setMaxSize:)]
|
|
|
|
|
pub(crate) fn setMaxSize(&self, maxSize: NSSize);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setResizeIncrements:)]
|
|
|
|
|
pub(crate) fn setResizeIncrements(&self, increments: NSSize);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(contentResizeIncrements)]
|
|
|
|
|
pub(crate) fn contentResizeIncrements(&self) -> NSSize;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setContentResizeIncrements:)]
|
|
|
|
|
pub(crate) fn setContentResizeIncrements(&self, increments: NSSize);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setFrame:display:)]
|
|
|
|
|
pub(crate) fn setFrame_display(&self, frameRect: NSRect, flag: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setMovable:)]
|
|
|
|
|
pub(crate) fn setMovable(&self, movable: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setSharingType:)]
|
|
|
|
|
pub(crate) fn setSharingType(&self, sharingType: NSWindowSharingType);
|
2022-11-23 15:51:34 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setTabbingMode:)]
|
|
|
|
|
pub(crate) fn setTabbingMode(&self, tabbingMode: NSWindowTabbingMode);
|
2023-07-13 21:14:04 -07:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setOpaque:)]
|
|
|
|
|
pub(crate) fn setOpaque(&self, opaque: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(hasShadow)]
|
|
|
|
|
pub(crate) fn hasShadow(&self) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setHasShadow:)]
|
|
|
|
|
pub(crate) fn setHasShadow(&self, has_shadow: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setIgnoresMouseEvents:)]
|
|
|
|
|
pub(crate) fn setIgnoresMouseEvents(&self, ignores: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setBackgroundColor:)]
|
|
|
|
|
pub(crate) fn setBackgroundColor(&self, color: &NSColor);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(styleMask)]
|
|
|
|
|
pub(crate) fn styleMask(&self) -> NSWindowStyleMask;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setStyleMask:)]
|
|
|
|
|
pub(crate) fn setStyleMask(&self, mask: NSWindowStyleMask);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(registerForDraggedTypes:)]
|
|
|
|
|
pub(crate) fn registerForDraggedTypes(&self, types: &NSArray<NSPasteboardType>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(makeKeyAndOrderFront:)]
|
|
|
|
|
pub(crate) fn makeKeyAndOrderFront(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(orderFront:)]
|
|
|
|
|
pub(crate) fn orderFront(&self, sender: Option<&Object>);
|
2023-01-27 07:08:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(miniaturize:)]
|
|
|
|
|
pub(crate) fn miniaturize(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(sender:)]
|
|
|
|
|
pub(crate) fn deminiaturize(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(toggleFullScreen:)]
|
|
|
|
|
pub(crate) fn toggleFullScreen(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(orderOut:)]
|
|
|
|
|
pub(crate) fn orderOut(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(zoom:)]
|
|
|
|
|
pub(crate) fn zoom(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(selectNextKeyView:)]
|
|
|
|
|
pub(crate) fn selectNextKeyView(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(selectPreviousKeyView:)]
|
|
|
|
|
pub(crate) fn selectPreviousKeyView(&self, sender: Option<&Object>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(firstResponder)]
|
|
|
|
|
pub(crate) fn firstResponder(&self) -> Option<Id<NSResponder>>;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(standardWindowButton:)]
|
|
|
|
|
pub(crate) fn standardWindowButton(&self, kind: NSWindowButton) -> Option<Id<NSButton>>;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setTitle:)]
|
|
|
|
|
pub(crate) fn setTitle(&self, title: &NSString);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(title)]
|
|
|
|
|
pub(crate) fn title_(&self) -> Id<NSString>;
|
2022-11-03 10:11:37 -07:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setReleasedWhenClosed:)]
|
|
|
|
|
pub(crate) fn setReleasedWhenClosed(&self, val: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setAcceptsMouseMovedEvents:)]
|
|
|
|
|
pub(crate) fn setAcceptsMouseMovedEvents(&self, val: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setTitlebarAppearsTransparent:)]
|
|
|
|
|
pub(crate) fn setTitlebarAppearsTransparent(&self, val: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setTitleVisibility:)]
|
|
|
|
|
pub(crate) fn setTitleVisibility(&self, visibility: NSWindowTitleVisibility);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setMovableByWindowBackground:)]
|
|
|
|
|
pub(crate) fn setMovableByWindowBackground(&self, val: bool);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setLevel:)]
|
|
|
|
|
pub(crate) fn setLevel(&self, level: NSWindowLevel);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setAllowsAutomaticWindowTabbing:)]
|
|
|
|
|
pub(crate) fn setAllowsAutomaticWindowTabbing(val: bool);
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setTabbingIdentifier:)]
|
|
|
|
|
pub(crate) fn setTabbingIdentifier(&self, identifier: &NSString);
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setDocumentEdited:)]
|
|
|
|
|
pub(crate) fn setDocumentEdited(&self, val: bool);
|
2022-11-23 17:07:41 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(occlusionState)]
|
|
|
|
|
pub(crate) fn occlusionState(&self) -> NSWindowOcclusionState;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(center)]
|
|
|
|
|
pub(crate) fn center(&self);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isResizable)]
|
|
|
|
|
pub(crate) fn isResizable(&self) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isMiniaturizable)]
|
|
|
|
|
pub(crate) fn isMiniaturizable(&self) -> bool;
|
2022-11-29 12:03:51 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(hasCloseBox)]
|
|
|
|
|
pub(crate) fn hasCloseBox(&self) -> bool;
|
2022-11-29 12:03:51 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isMiniaturized)]
|
|
|
|
|
pub(crate) fn isMiniaturized(&self) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isVisible)]
|
|
|
|
|
pub(crate) fn isVisible(&self) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isKeyWindow)]
|
|
|
|
|
pub(crate) fn isKeyWindow(&self) -> bool;
|
2023-01-17 03:30:14 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isZoomed)]
|
|
|
|
|
pub(crate) fn isZoomed(&self) -> bool;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(allowsAutomaticWindowTabbing)]
|
|
|
|
|
pub(crate) fn allowsAutomaticWindowTabbing() -> bool;
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(selectNextTab)]
|
|
|
|
|
pub(crate) fn selectNextTab(&self);
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(tabbingIdentifier)]
|
|
|
|
|
pub(crate) fn tabbingIdentifier(&self) -> Id<NSString>;
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method_id(tabGroup)]
|
|
|
|
|
pub(crate) fn tabGroup(&self) -> Id<NSWindowTabGroup>;
|
2023-07-13 06:52:34 +00:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(isDocumentEdited)]
|
|
|
|
|
pub(crate) fn isDocumentEdited(&self) -> bool;
|
2022-11-23 17:07:41 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(close)]
|
|
|
|
|
pub(crate) fn close(&self);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(performWindowDragWithEvent:)]
|
2022-09-08 16:45:29 +02:00
|
|
|
// TODO: Can this actually accept NULL?
|
2023-07-29 00:33:03 +02:00
|
|
|
pub(crate) fn performWindowDragWithEvent(&self, event: Option<&NSEvent>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(invalidateCursorRectsForView:)]
|
|
|
|
|
pub(crate) fn invalidateCursorRectsForView(&self, view: &NSView);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(setDelegate:)]
|
|
|
|
|
pub(crate) fn setDelegate(&self, delegate: Option<&NSObject>);
|
2022-09-08 16:45:29 +02:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(sendEvent:)]
|
|
|
|
|
pub(crate) unsafe fn sendEvent(&self, event: &NSEvent);
|
2022-12-22 08:07:13 +08:00
|
|
|
|
2023-07-29 00:33:03 +02:00
|
|
|
#[method(addChildWindow:ordered:)]
|
|
|
|
|
pub(crate) unsafe fn addChildWindow(&self, child: &NSWindow, ordered: NSWindowOrderingMode);
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(isize)] // NSInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSWindowTitleVisibility {
|
|
|
|
|
#[doc(alias = "NSWindowTitleVisible")]
|
|
|
|
|
Visible = 0,
|
|
|
|
|
#[doc(alias = "NSWindowTitleHidden")]
|
|
|
|
|
Hidden = 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowTitleVisibility {
|
|
|
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(usize)] // NSUInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSWindowButton {
|
|
|
|
|
#[doc(alias = "NSWindowCloseButton")]
|
|
|
|
|
Close = 0,
|
|
|
|
|
#[doc(alias = "NSWindowMiniaturizeButton")]
|
|
|
|
|
Miniaturize = 1,
|
|
|
|
|
#[doc(alias = "NSWindowZoomButton")]
|
|
|
|
|
Zoom = 2,
|
|
|
|
|
#[doc(alias = "NSWindowToolbarButton")]
|
|
|
|
|
Toolbar = 3,
|
|
|
|
|
#[doc(alias = "NSWindowDocumentIconButton")]
|
|
|
|
|
DocumentIcon = 4,
|
|
|
|
|
#[doc(alias = "NSWindowDocumentVersionsButton")]
|
|
|
|
|
DocumentVersions = 6,
|
|
|
|
|
#[doc(alias = "NSWindowFullScreenButton")]
|
|
|
|
|
#[deprecated = "Deprecated since macOS 10.12"]
|
|
|
|
|
FullScreen = 7,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowButton {
|
|
|
|
|
const ENCODING: Encoding = NSUInteger::ENCODING;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 11:08:56 +01:00
|
|
|
// CGWindowLevel.h
|
|
|
|
|
//
|
|
|
|
|
// Note: There are two different things at play in this header:
|
|
|
|
|
// `CGWindowLevel` and `CGWindowLevelKey`.
|
|
|
|
|
//
|
|
|
|
|
// It seems like there was a push towards using "key" values instead of the
|
|
|
|
|
// raw window level values, and then you were supposed to use
|
|
|
|
|
// `CGWindowLevelForKey` to get the actual level.
|
|
|
|
|
//
|
|
|
|
|
// But the values that `NSWindowLevel` has are compiled in, and as such has
|
|
|
|
|
// to remain ABI compatible, so they're safe for us to hardcode as well.
|
2022-09-08 16:45:29 +02:00
|
|
|
#[allow(dead_code)]
|
2022-11-22 11:08:56 +01:00
|
|
|
mod window_level {
|
|
|
|
|
const kCGNumReservedWindowLevels: i32 = 16;
|
|
|
|
|
const kCGNumReservedBaseWindowLevels: i32 = 5;
|
|
|
|
|
|
|
|
|
|
pub const kCGBaseWindowLevel: i32 = i32::MIN;
|
|
|
|
|
pub const kCGMinimumWindowLevel: i32 = kCGBaseWindowLevel + kCGNumReservedBaseWindowLevels;
|
|
|
|
|
pub const kCGMaximumWindowLevel: i32 = i32::MAX - kCGNumReservedWindowLevels;
|
|
|
|
|
|
|
|
|
|
pub const kCGDesktopWindowLevel: i32 = kCGMinimumWindowLevel + 20;
|
|
|
|
|
pub const kCGDesktopIconWindowLevel: i32 = kCGDesktopWindowLevel + 20;
|
|
|
|
|
pub const kCGBackstopMenuLevel: i32 = -20;
|
|
|
|
|
pub const kCGNormalWindowLevel: i32 = 0;
|
|
|
|
|
pub const kCGFloatingWindowLevel: i32 = 3;
|
|
|
|
|
pub const kCGTornOffMenuWindowLevel: i32 = 3;
|
|
|
|
|
pub const kCGModalPanelWindowLevel: i32 = 8;
|
|
|
|
|
pub const kCGUtilityWindowLevel: i32 = 19;
|
|
|
|
|
pub const kCGDockWindowLevel: i32 = 20;
|
|
|
|
|
pub const kCGMainMenuWindowLevel: i32 = 24;
|
|
|
|
|
pub const kCGStatusWindowLevel: i32 = 25;
|
|
|
|
|
pub const kCGPopUpMenuWindowLevel: i32 = 101;
|
|
|
|
|
pub const kCGOverlayWindowLevel: i32 = 102;
|
|
|
|
|
pub const kCGHelpWindowLevel: i32 = 200;
|
|
|
|
|
pub const kCGDraggingWindowLevel: i32 = 500;
|
|
|
|
|
pub const kCGScreenSaverWindowLevel: i32 = 1000;
|
|
|
|
|
pub const kCGAssistiveTechHighWindowLevel: i32 = 1500;
|
|
|
|
|
pub const kCGCursorWindowLevel: i32 = kCGMaximumWindowLevel - 1;
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
2022-11-22 11:08:56 +01:00
|
|
|
use window_level::*;
|
2022-09-08 16:45:29 +02:00
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
2022-11-22 11:08:56 +01:00
|
|
|
#[repr(transparent)]
|
|
|
|
|
pub struct NSWindowLevel(pub NSInteger);
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
impl NSWindowLevel {
|
2022-11-26 03:50:58 +02:00
|
|
|
#[doc(alias = "BelowNormalWindowLevel")]
|
|
|
|
|
pub const BELOW_NORMAL: Self = Self((kCGNormalWindowLevel - 1) as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSNormalWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const Normal: Self = Self(kCGNormalWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSFloatingWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const Floating: Self = Self(kCGFloatingWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSTornOffMenuWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const TornOffMenu: Self = Self(kCGTornOffMenuWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSModalPanelWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const ModalPanel: Self = Self(kCGModalPanelWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSMainMenuWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const MainMenu: Self = Self(kCGMainMenuWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSStatusWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const Status: Self = Self(kCGStatusWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSPopUpMenuWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const PopUpMenu: Self = Self(kCGPopUpMenuWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
#[doc(alias = "NSScreenSaverWindowLevel")]
|
2022-11-22 11:08:56 +01:00
|
|
|
pub const ScreenSaver: Self = Self(kCGScreenSaverWindowLevel as _);
|
2022-09-08 16:45:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowLevel {
|
|
|
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bitflags! {
|
2023-06-02 15:44:36 +01:00
|
|
|
#[derive(Clone, Copy)]
|
2022-09-08 16:45:29 +02:00
|
|
|
pub struct NSWindowOcclusionState: NSUInteger {
|
|
|
|
|
const NSWindowOcclusionStateVisible = 1 << 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowOcclusionState {
|
|
|
|
|
const ENCODING: Encoding = NSUInteger::ENCODING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bitflags! {
|
2023-06-02 15:44:36 +01:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2022-09-08 16:45:29 +02:00
|
|
|
pub struct NSWindowStyleMask: NSUInteger {
|
|
|
|
|
const NSBorderlessWindowMask = 0;
|
|
|
|
|
const NSTitledWindowMask = 1 << 0;
|
|
|
|
|
const NSClosableWindowMask = 1 << 1;
|
|
|
|
|
const NSMiniaturizableWindowMask = 1 << 2;
|
|
|
|
|
const NSResizableWindowMask = 1 << 3;
|
|
|
|
|
const NSTexturedBackgroundWindowMask = 1 << 8;
|
|
|
|
|
const NSUnifiedTitleAndToolbarWindowMask = 1 << 12;
|
|
|
|
|
const NSFullScreenWindowMask = 1 << 14;
|
|
|
|
|
const NSFullSizeContentViewWindowMask = 1 << 15;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowStyleMask {
|
|
|
|
|
const ENCODING: Encoding = NSUInteger::ENCODING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(usize)] // NSUInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSBackingStoreType {
|
|
|
|
|
NSBackingStoreRetained = 0,
|
|
|
|
|
NSBackingStoreNonretained = 1,
|
|
|
|
|
NSBackingStoreBuffered = 2,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSBackingStoreType {
|
|
|
|
|
const ENCODING: Encoding = NSUInteger::ENCODING;
|
|
|
|
|
}
|
2022-11-23 15:51:34 +02:00
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(usize)] // NSUInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSWindowSharingType {
|
|
|
|
|
NSWindowSharingNone = 0,
|
|
|
|
|
NSWindowSharingReadOnly = 1,
|
|
|
|
|
NSWindowSharingReadWrite = 2,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowSharingType {
|
|
|
|
|
const ENCODING: Encoding = NSUInteger::ENCODING;
|
|
|
|
|
}
|
2022-12-22 08:07:13 +08:00
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(isize)] // NSInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSWindowOrderingMode {
|
|
|
|
|
NSWindowAbove = 1,
|
|
|
|
|
NSWindowBelow = -1,
|
|
|
|
|
NSWindowOut = 0,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowOrderingMode {
|
|
|
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
|
|
|
}
|
2023-07-13 21:14:04 -07:00
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(isize)] // NSInteger
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
pub enum NSWindowTabbingMode {
|
|
|
|
|
NSWindowTabbingModeAutomatic = 0,
|
|
|
|
|
NSWindowTabbingModeDisallowed = 2,
|
|
|
|
|
NSWindowTabbingModePreferred = 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsafe impl Encode for NSWindowTabbingMode {
|
|
|
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
|
|
|
}
|