From c519abad4744c188622206a7f2e08351e7814078 Mon Sep 17 00:00:00 2001 From: Phil Dennis-Jordan Date: Fri, 26 Mar 2021 15:49:20 +0100 Subject: [PATCH] Adds function for fetching ID of a core_graphics::display::CGDisplayMode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a mode_id() function on CGDisplayMode which returns the unique (to that display) integer ID the system uses to identify the display mode. It internally calls down to CGDisplayModeGetIODisplayModeID() in the CoreGraphics framework. The FFI for this function was previously missing and has also been added. --- core-graphics/src/display.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core-graphics/src/display.rs b/core-graphics/src/display.rs index f677408..394520b 100644 --- a/core-graphics/src/display.rs +++ b/core-graphics/src/display.rs @@ -608,6 +608,10 @@ impl CGDisplayMode { 0 } } + + pub fn mode_id(&self) -> i32 { + unsafe { CGDisplayModeGetIODisplayModeID(self.as_ptr()) } + } } #[link(name = "CoreGraphics", kind = "framework")] @@ -686,6 +690,7 @@ extern "C" { pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double; pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> u32; pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef; + pub fn CGDisplayModeGetIODisplayModeID(mode: ::sys::CGDisplayModeRef) -> i32; pub fn CGDisplayCopyAllDisplayModes( display: CGDirectDisplayID,