Skip to content

Commit c519aba

Browse files
committed
Adds function for fetching ID of a core_graphics::display::CGDisplayMode
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.
1 parent 4c52fbd commit c519aba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core-graphics/src/display.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ impl CGDisplayMode {
608608
0
609609
}
610610
}
611+
612+
pub fn mode_id(&self) -> i32 {
613+
unsafe { CGDisplayModeGetIODisplayModeID(self.as_ptr()) }
614+
}
611615
}
612616

613617
#[link(name = "CoreGraphics", kind = "framework")]
@@ -686,6 +690,7 @@ extern "C" {
686690
pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double;
687691
pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> u32;
688692
pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef;
693+
pub fn CGDisplayModeGetIODisplayModeID(mode: ::sys::CGDisplayModeRef) -> i32;
689694

690695
pub fn CGDisplayCopyAllDisplayModes(
691696
display: CGDirectDisplayID,

0 commit comments

Comments
 (0)