use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
pub const kCGMouseDownEventMaskingDeadSwitchTimeout: c_float = 60.0;
pub const kCGEventFilterMaskPermitAllEvents: c_uint = CGEventFilterMask::PermitLocalMouseEvents.0
| CGEventFilterMask::PermitLocalKeyboardEvents.0
| CGEventFilterMask::PermitSystemDefinedEvents.0;
pub const kCGEventSupressionStateSupressionInterval: c_uint =
CGEventSuppressionState::EventSuppressionStateSuppressionInterval.0;
pub const kCGEventSupressionStateRemoteMouseDrag: c_uint =
CGEventSuppressionState::EventSuppressionStateRemoteMouseDrag.0;
pub const kCGNumberOfEventSupressionStates: c_uint =
CGEventSuppressionState::NumberOfEventSuppressionStates.0;
#[cfg(feature = "CGError")]
pub type CGEventErr = CGError;
pub type CGButtonCount = u32;
pub type CGWheelCount = u32;
pub type CGCharCode = u16;
pub type CGKeyCode = u16;
pub type CGScreenRefreshCallback =
Option<unsafe extern "C-unwind" fn(u32, NonNull<CGRect>, *mut c_void)>;
extern "C-unwind" {
#[cfg(feature = "CGError")]
#[deprecated = "No longer supported"]
pub fn CGRegisterScreenRefreshCallback(
callback: CGScreenRefreshCallback,
user_info: *mut c_void,
) -> CGError;
}
extern "C-unwind" {
#[deprecated = "No longer supported"]
pub fn CGUnregisterScreenRefreshCallback(
callback: CGScreenRefreshCallback,
user_info: *mut c_void,
);
}
extern "C-unwind" {
#[cfg(feature = "CGError")]
#[deprecated = "No longer supported"]
pub fn CGWaitForScreenRefreshRects(rects: *mut *mut CGRect, count: *mut u32) -> CGError;
}
#[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);
}
#[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);
}
pub type CGScreenUpdateMoveCallback = Option<
unsafe extern "C-unwind" fn(CGScreenUpdateMoveDelta, usize, NonNull<CGRect>, *mut c_void),
>;
extern "C-unwind" {
#[cfg(feature = "CGError")]
#[deprecated = "No longer supported"]
pub fn CGScreenRegisterMoveCallback(
callback: CGScreenUpdateMoveCallback,
user_info: *mut c_void,
) -> CGError;
}
extern "C-unwind" {
#[deprecated = "No longer supported"]
pub fn CGScreenUnregisterMoveCallback(
callback: CGScreenUpdateMoveCallback,
user_info: *mut c_void,
);
}
extern "C-unwind" {
#[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" {
#[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 _) }
}
#[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);
}
#[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) })
}
pub type CGRectCount = u32;