From 066201f910da5811739d821ef9fe75c4e085a6ae Mon Sep 17 00:00:00 2001 From: David Partouche Date: Tue, 4 Nov 2014 17:44:07 +0100 Subject: [PATCH] Added some Quartz Display Services functions (used in glutin) --- src/base.rs | 1 + src/display.rs | 26 ++++++++++++++++++++++++++ src/lib.rs | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 src/display.rs diff --git a/src/base.rs b/src/base.rs index b9d5061..d100603 100644 --- a/src/base.rs +++ b/src/base.rs @@ -13,6 +13,7 @@ use libc; // TODO: this is actually a libc::c_float on 32bit pub type CGFloat = libc::c_double; +pub type CGError = libc::int32_t; pub type CGAffineTransform = (); diff --git a/src/display.rs b/src/display.rs new file mode 100644 index 0000000..a985bdb --- /dev/null +++ b/src/display.rs @@ -0,0 +1,26 @@ +// Copyright 2013 The Servo Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this file defines CGFloat, as well as stubbed data types. + +use libc; +use base::CGError; + +pub type CGDirectDisplayID = libc::uint32_t; + +#[link(name = "ApplicationServices", kind = "framework")] +extern { + pub fn CGMainDisplayID() -> CGDirectDisplayID; + 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; +} diff --git a/src/lib.rs b/src/lib.rs index 30383a1..b13b204 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,3 +21,5 @@ pub mod data_provider; pub mod font; #[cfg(target_os="macos")] pub mod geometry; +#[cfg(target_os="macos")] +pub mod quartz_display_services;