|
9 | 9 |
|
10 | 10 | #![allow(non_upper_case_globals)]
|
11 | 11 |
|
| 12 | +use bitflags::bitflags; |
12 | 13 | use libc;
|
13 | 14 | use std::ops::Deref;
|
14 | 15 | use std::ptr;
|
@@ -110,6 +111,41 @@ pub enum CGConfigureOption {
|
110 | 111 | ConfigurePermanently = 2,
|
111 | 112 | }
|
112 | 113 |
|
| 114 | +/// A client-supplied callback function that’s invoked whenever the configuration of a local display is changed. |
| 115 | +pub type CGDisplayReconfigurationCallBack = |
| 116 | + unsafe extern "C" fn(display: CGDirectDisplayID, flags: u32, user_info: *const libc::c_void); |
| 117 | + |
| 118 | +bitflags! { |
| 119 | + /// The configuration parameters that are passed to a display reconfiguration callback function. |
| 120 | + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 121 | + pub struct CGDisplayChangeSummaryFlags: u32 { |
| 122 | + /// The display configuration is about to change. |
| 123 | + const kCGDisplayBeginConfigurationFlag = 1; |
| 124 | + /// The location of the upper-left corner of the display in the global display coordinate space has changed. |
| 125 | + const kCGDisplayMovedFlag = 1 << 1; |
| 126 | + /// The display is now the main display. |
| 127 | + const kCGDisplaySetMainFlag = 1 << 2; |
| 128 | + /// The display mode has changed. |
| 129 | + const kCGDisplaySetModeFlag = 1 << 3; |
| 130 | + /// The display has been added to the active display list. |
| 131 | + const kCGDisplayAddFlag = 1 << 4; |
| 132 | + /// The display has been removed from the active display list. |
| 133 | + const kCGDisplayRemoveFlag = 1 << 5; |
| 134 | + /// The display has been enabled. |
| 135 | + const kCGDisplayEnabledFlag = 1 << 8; |
| 136 | + /// The display has been disabled. |
| 137 | + const kCGDisplayDisabledFlag = 1 << 9; |
| 138 | + /// The display is now mirroring another display. |
| 139 | + const kCGDisplayMirrorFlag = 1 << 10; |
| 140 | + /// The display is no longer mirroring another display. |
| 141 | + const kCGDisplayUnMirrorFlag = 1 << 11; |
| 142 | + /// The shape of the desktop (the union of display areas) has changed. |
| 143 | + const kCGDisplayDesktopShapeChangedFlag = 1 << 12; |
| 144 | + |
| 145 | + const _ = !0; |
| 146 | + } |
| 147 | +} |
| 148 | + |
113 | 149 | #[derive(Copy, Clone, Debug)]
|
114 | 150 | pub struct CGDisplay {
|
115 | 151 | pub id: CGDirectDisplayID,
|
@@ -724,6 +760,14 @@ extern "C" {
|
724 | 760 | y: i32,
|
725 | 761 | ) -> CGError;
|
726 | 762 | pub fn CGRestorePermanentDisplayConfiguration();
|
| 763 | + pub fn CGDisplayRegisterReconfigurationCallback( |
| 764 | + callback: CGDisplayReconfigurationCallBack, |
| 765 | + user_info: *const libc::c_void, |
| 766 | + ) -> CGError; |
| 767 | + pub fn CGDisplayRemoveReconfigurationCallback( |
| 768 | + callback: CGDisplayReconfigurationCallBack, |
| 769 | + user_info: *const libc::c_void, |
| 770 | + ) -> CGError; |
727 | 771 |
|
728 | 772 | pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> crate::sys::CGDisplayModeRef;
|
729 | 773 | pub fn CGDisplayModeGetHeight(mode: crate::sys::CGDisplayModeRef) -> libc::size_t;
|
|
0 commit comments