objc2-core-graphics 0.3.2

Bindings to the CoreGraphics framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgmousedowneventmaskingdeadswitchtimeout?language=objc)
pub const kCGMouseDownEventMaskingDeadSwitchTimeout: c_float = 60.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgeventfiltermaskpermitallevents?language=objc)
pub const kCGEventFilterMaskPermitAllEvents: c_uint = CGEventFilterMask::PermitLocalMouseEvents.0
    | CGEventFilterMask::PermitLocalKeyboardEvents.0
    | CGEventFilterMask::PermitSystemDefinedEvents.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgeventsupressionstatesupressioninterval?language=objc)
pub const kCGEventSupressionStateSupressionInterval: c_uint =
    CGEventSuppressionState::EventSuppressionStateSuppressionInterval.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgeventsupressionstateremotemousedrag?language=objc)
pub const kCGEventSupressionStateRemoteMouseDrag: c_uint =
    CGEventSuppressionState::EventSuppressionStateRemoteMouseDrag.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/kcgnumberofeventsupressionstates?language=objc)
pub const kCGNumberOfEventSupressionStates: c_uint =
    CGEventSuppressionState::NumberOfEventSuppressionStates.0;
/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgeventerr?language=objc)
#[cfg(feature = "CGError")]
pub type CGEventErr = CGError;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgbuttoncount?language=objc)
pub type CGButtonCount = u32;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgwheelcount?language=objc)
pub type CGWheelCount = u32;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgcharcode?language=objc)
pub type CGCharCode = u16;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgkeycode?language=objc)
pub type CGKeyCode = u16;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgscreenrefreshcallback?language=objc)
pub type CGScreenRefreshCallback =
    Option<unsafe extern "C-unwind" fn(u32, NonNull<CGRect>, *mut c_void)>;

extern "C-unwind" {
    /// # Safety
    ///
    /// - `callback` must be implemented correctly.
    /// - `user_info` must be a valid pointer or null.
    #[cfg(feature = "CGError")]
    #[deprecated = "No longer supported"]
    pub fn CGRegisterScreenRefreshCallback(
        callback: CGScreenRefreshCallback,
        user_info: *mut c_void,
    ) -> CGError;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `callback` must be implemented correctly.
    /// - `user_info` must be a valid pointer or null.
    #[deprecated = "No longer supported"]
    pub fn CGUnregisterScreenRefreshCallback(
        callback: CGScreenRefreshCallback,
        user_info: *mut c_void,
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `rects` must be a valid pointer or null.
    /// - `count` must be a valid pointer or null.
    #[cfg(feature = "CGError")]
    #[deprecated = "No longer supported"]
    pub fn CGWaitForScreenRefreshRects(rects: *mut *mut CGRect, count: *mut u32) -> CGError;
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgscreenupdateoperation?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CGScreenUpdateOperation(pub u32);
bitflags::bitflags! {
    impl CGScreenUpdateOperation: u32 {
        #[doc(alias = "kCGScreenUpdateOperationRefresh")]
        const Refresh = 0;
        #[doc(alias = "kCGScreenUpdateOperationMove")]
        const Move = 1<<0;
        #[doc(alias = "kCGScreenUpdateOperationReducedDirtyRectangleCount")]
        const ReducedDirtyRectangleCount = 1<<31;
    }
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGScreenUpdateOperation {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGScreenUpdateOperation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgscreenupdatemovedelta?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CGScreenUpdateMoveDelta {
    pub dX: i32,
    pub dY: i32,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGScreenUpdateMoveDelta {
    const ENCODING: Encoding = Encoding::Struct(
        "CGScreenUpdateMoveDelta",
        &[<i32>::ENCODING, <i32>::ENCODING],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGScreenUpdateMoveDelta {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgscreenupdatemovecallback?language=objc)
pub type CGScreenUpdateMoveCallback = Option<
    unsafe extern "C-unwind" fn(CGScreenUpdateMoveDelta, usize, NonNull<CGRect>, *mut c_void),
>;

extern "C-unwind" {
    /// # Safety
    ///
    /// - `callback` must be implemented correctly.
    /// - `user_info` must be a valid pointer or null.
    #[cfg(feature = "CGError")]
    #[deprecated = "No longer supported"]
    pub fn CGScreenRegisterMoveCallback(
        callback: CGScreenUpdateMoveCallback,
        user_info: *mut c_void,
    ) -> CGError;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `callback` must be implemented correctly.
    /// - `user_info` must be a valid pointer or null.
    #[deprecated = "No longer supported"]
    pub fn CGScreenUnregisterMoveCallback(
        callback: CGScreenUpdateMoveCallback,
        user_info: *mut c_void,
    );
}

extern "C-unwind" {
    /// # Safety
    ///
    /// - `current_operation` must be a valid pointer or null.
    /// - `rects` must be a valid pointer or null.
    /// - `rect_count` must be a valid pointer or null.
    /// - `delta` must be a valid pointer or null.
    #[cfg(feature = "CGError")]
    #[deprecated = "No longer supported"]
    pub fn CGWaitForScreenUpdateRects(
        requested_operations: CGScreenUpdateOperation,
        current_operation: *mut CGScreenUpdateOperation,
        rects: *mut *mut CGRect,
        rect_count: *mut usize,
        delta: *mut CGScreenUpdateMoveDelta,
    ) -> CGError;
}

extern "C-unwind" {
    /// # Safety
    ///
    /// `rects` must be a valid pointer or null.
    #[deprecated = "No longer supported"]
    pub fn CGReleaseScreenRefreshRects(rects: *mut CGRect);
}

#[cfg(feature = "libc")]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGCursorIsVisible() -> bool {
    extern "C-unwind" {
        fn CGCursorIsVisible() -> libc::boolean_t;
    }
    let ret = unsafe { CGCursorIsVisible() };
    ret != 0
}

#[cfg(feature = "libc")]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGCursorIsDrawnInFramebuffer() -> bool {
    extern "C-unwind" {
        fn CGCursorIsDrawnInFramebuffer() -> libc::boolean_t;
    }
    let ret = unsafe { CGCursorIsDrawnInFramebuffer() };
    ret != 0
}

#[cfg(feature = "CGError")]
#[inline]
pub extern "C-unwind" fn CGWarpMouseCursorPosition(new_cursor_position: CGPoint) -> CGError {
    extern "C-unwind" {
        fn CGWarpMouseCursorPosition(new_cursor_position: CGPoint) -> CGError;
    }
    unsafe { CGWarpMouseCursorPosition(new_cursor_position) }
}

#[cfg(all(feature = "CGError", feature = "libc"))]
#[inline]
pub extern "C-unwind" fn CGAssociateMouseAndMouseCursorPosition(connected: bool) -> CGError {
    extern "C-unwind" {
        fn CGAssociateMouseAndMouseCursorPosition(connected: libc::boolean_t) -> CGError;
    }
    unsafe { CGAssociateMouseAndMouseCursorPosition(connected as _) }
}

#[inline]
pub extern "C-unwind" fn CGWindowServerCreateServerPort() -> Option<CFRetained<CFMachPort>> {
    extern "C-unwind" {
        fn CGWindowServerCreateServerPort() -> Option<NonNull<CFMachPort>>;
    }
    let ret = unsafe { CGWindowServerCreateServerPort() };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CGError", feature = "libc"))]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGEnableEventStateCombining(combine_state: bool) -> CGError {
    extern "C-unwind" {
        fn CGEnableEventStateCombining(combine_state: libc::boolean_t) -> CGError;
    }
    unsafe { CGEnableEventStateCombining(combine_state as _) }
}

#[cfg(all(feature = "CGError", feature = "libc"))]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGInhibitLocalEvents(inhibit: bool) -> CGError {
    extern "C-unwind" {
        fn CGInhibitLocalEvents(inhibit: libc::boolean_t) -> CGError;
    }
    unsafe { CGInhibitLocalEvents(inhibit as _) }
}

#[cfg(all(feature = "CGError", feature = "libc"))]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGPostKeyboardEvent(
    key_char: CGCharCode,
    virtual_key: CGKeyCode,
    key_down: bool,
) -> CGError {
    extern "C-unwind" {
        fn CGPostKeyboardEvent(
            key_char: CGCharCode,
            virtual_key: CGKeyCode,
            key_down: libc::boolean_t,
        ) -> CGError;
    }
    unsafe { CGPostKeyboardEvent(key_char, virtual_key, key_down as _) }
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgeventfiltermask?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CGEventFilterMask(pub u32);
bitflags::bitflags! {
    impl CGEventFilterMask: u32 {
        #[doc(alias = "kCGEventFilterMaskPermitLocalMouseEvents")]
        const PermitLocalMouseEvents = 0x00000001;
        #[doc(alias = "kCGEventFilterMaskPermitLocalKeyboardEvents")]
        const PermitLocalKeyboardEvents = 0x00000002;
        #[doc(alias = "kCGEventFilterMaskPermitSystemDefinedEvents")]
        const PermitSystemDefinedEvents = 0x00000004;
    }
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGEventFilterMask {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGEventFilterMask {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgeventsuppressionstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CGEventSuppressionState(pub u32);
impl CGEventSuppressionState {
    #[doc(alias = "kCGEventSuppressionStateSuppressionInterval")]
    pub const EventSuppressionStateSuppressionInterval: Self = Self(0);
    #[doc(alias = "kCGEventSuppressionStateRemoteMouseDrag")]
    pub const EventSuppressionStateRemoteMouseDrag: Self = Self(1);
    #[doc(alias = "kCGNumberOfEventSuppressionStates")]
    pub const NumberOfEventSuppressionStates: Self = Self(2);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGEventSuppressionState {
    const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for CGEventSuppressionState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "CGError")]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGSetLocalEventsFilterDuringSuppressionState(
    filter: CGEventFilterMask,
    state: CGEventSuppressionState,
) -> CGError {
    extern "C-unwind" {
        fn CGSetLocalEventsFilterDuringSuppressionState(
            filter: CGEventFilterMask,
            state: CGEventSuppressionState,
        ) -> CGError;
    }
    unsafe { CGSetLocalEventsFilterDuringSuppressionState(filter, state) }
}

#[cfg(feature = "CGError")]
#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGSetLocalEventsSuppressionInterval(seconds: CFTimeInterval) -> CGError {
    extern "C-unwind" {
        fn CGSetLocalEventsSuppressionInterval(seconds: CFTimeInterval) -> CGError;
    }
    unsafe { CGSetLocalEventsSuppressionInterval(seconds) }
}

#[deprecated = "No longer supported"]
#[inline]
pub extern "C-unwind" fn CGWindowServerCFMachPort() -> Option<CFRetained<CFMachPort>> {
    extern "C-unwind" {
        fn CGWindowServerCFMachPort() -> Option<NonNull<CFMachPort>>;
    }
    let ret = unsafe { CGWindowServerCFMachPort() };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgrectcount?language=objc)
pub type CGRectCount = u32;