From ef6fc9865b64d712dddad3fa94eff0200722742a Mon Sep 17 00:00:00 2001 From: Felix Kaaman Date: Mon, 4 May 2015 09:24:34 +0200 Subject: [PATCH] Add some more functions and make geometry structs #[repr(C)] --- src/base.rs | 5 +++++ src/display.rs | 29 ++++++++++++++++++++++++++++- src/geometry.rs | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index d100603..94d8249 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,6 +11,11 @@ use libc; +#[cfg(target_pointer_width = "32")] +pub type boolean_t = i32; +#[cfg(target_pointer_width = "64")] +pub type boolean_t = u32; + // TODO: this is actually a libc::c_float on 32bit pub type CGFloat = libc::c_double; pub type CGError = libc::int32_t; diff --git a/src/display.rs b/src/display.rs index a985bdb..02fa138 100644 --- a/src/display.rs +++ b/src/display.rs @@ -10,17 +10,44 @@ // this file defines CGFloat, as well as stubbed data types. use libc; -use base::CGError; +use base::{CGError, boolean_t}; +use geometry::{CGRect, CGPoint, CGSize}; pub type CGDirectDisplayID = libc::uint32_t; #[link(name = "ApplicationServices", kind = "framework")] extern { pub fn CGMainDisplayID() -> CGDirectDisplayID; + pub fn CGDisplayIsActive(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsAlwaysInMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsAsleep(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsBuiltin(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsInHWMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsInMirrorSet(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsMain(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsOnline(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayIsStereo(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayMirrorsDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; + pub fn CGDisplayPrimaryDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; + pub fn CGDisplayRotation(display: CGDirectDisplayID) -> libc::c_double; + pub fn CGDisplayScreenSize(display: CGDirectDisplayID) -> CGSize; + pub fn CGDisplaySerialNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGDisplayUnitNumber(display: CGDirectDisplayID) -> libc::uint32_t; + pub fn CGDisplayUsesOpenGLAcceleration(display: CGDirectDisplayID) -> boolean_t; + pub fn CGDisplayVendorNumber(display: CGDirectDisplayID) -> libc::uint32_t; pub fn CGGetActiveDisplayList(max_displays: libc::uint32_t, active_displays: *mut CGDirectDisplayID, display_count: *mut libc::uint32_t) -> CGError; pub fn CGDisplayModelNumber(display: CGDirectDisplayID) -> libc::uint32_t; pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t; pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t; + pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect; + + // mouse stuff + pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError; + pub fn CGDisplayShowCursor(display: CGDirectDisplayID) -> CGError; + pub fn CGDisplayMoveCursorToPoint(display: CGDirectDisplayID, point: CGPoint) -> CGError; + pub fn CGWarpMouseCursorPosition(point: CGPoint) -> CGError; + pub fn CGAssociateMouseAndMouseCursorPosition(connected: bool) -> CGError; + } diff --git a/src/geometry.rs b/src/geometry.rs index 40f50a9..fbe1280 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -9,16 +9,19 @@ use base::CGFloat; +#[repr(C)] pub struct CGSize { pub width: CGFloat, pub height: CGFloat, } +#[repr(C)] pub struct CGPoint { pub x: CGFloat, pub y: CGFloat, } +#[repr(C)] pub struct CGRect { pub origin: CGPoint, pub size: CGSize