1 // Copyright 2013 The Servo Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution. 3 // 4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 // option. This file may not be copied, modified, or distributed 8 // except according to those terms. 9 10 #![allow(non_upper_case_globals)] 11 12 use libc; 13 use std::ptr; 14 use std::ops::Deref; 15 16 pub use base::{CGError, boolean_t}; 17 pub use geometry::{CGRect, CGPoint, CGSize}; 18 19 use core_foundation::string::{CFString, CFStringRef}; 20 use core_foundation::base::{CFRetain, TCFType}; 21 use image::CGImage; 22 use foreign_types::ForeignType; 23 24 pub type CGDirectDisplayID = libc::uint32_t; 25 pub type CGWindowID = libc::uint32_t; 26 27 pub const kCGNullWindowID: CGWindowID = 0 as CGWindowID; 28 29 30 pub type CGWindowListOption = libc::uint32_t; 31 32 pub const kCGWindowListOptionAll: CGWindowListOption = 0; 33 pub const kCGWindowListOptionOnScreenOnly: CGWindowListOption = 1 << 0; 34 pub const kCGWindowListOptionOnScreenAboveWindow: CGWindowListOption = 1 << 1; 35 pub const kCGWindowListOptionOnScreenBelowWindow: CGWindowListOption = 1 << 2; 36 pub const kCGWindowListOptionIncludingWindow: CGWindowListOption = 1 << 3; 37 pub const kCGWindowListExcludeDesktopElements: CGWindowListOption = 1 << 4; 38 39 pub type CGWindowImageOption = libc::uint32_t; 40 41 pub const kCGWindowImageDefault: CGWindowImageOption = 0; 42 pub const kCGWindowImageBoundsIgnoreFraming: CGWindowImageOption = 1 << 0; 43 pub const kCGWindowImageShouldBeOpaque: CGWindowImageOption = 1 << 1; 44 pub const kCGWindowImageOnlyShadows: CGWindowImageOption = 1 << 2; 45 pub const kCGWindowImageBestResolution: CGWindowImageOption = 1 << 3; 46 pub const kCGWindowImageNominalResolution: CGWindowImageOption = 1 << 4; 47 48 pub const kDisplayModeValidFlag: u32 = 0x00000001; 49 pub const kDisplayModeSafeFlag: u32 = 0x00000002; 50 pub const kDisplayModeDefaultFlag: u32 = 0x00000004; 51 pub const kDisplayModeAlwaysShowFlag: u32 = 0x00000008; 52 pub const kDisplayModeNeverShowFlag: u32 = 0x00000080; 53 pub const kDisplayModeNotResizeFlag: u32 = 0x00000010; 54 pub const kDisplayModeRequiresPanFlag: u32 = 0x00000020; 55 pub const kDisplayModeInterlacedFlag: u32 = 0x00000040; 56 pub const kDisplayModeSimulscanFlag: u32 = 0x00000100; 57 pub const kDisplayModeBuiltInFlag: u32 = 0x00000400; 58 pub const kDisplayModeNotPresetFlag: u32 = 0x00000200; 59 pub const kDisplayModeStretchedFlag: u32 = 0x00000800; 60 pub const kDisplayModeNotGraphicsQualityFlag: u32 = 0x00001000; 61 pub const kDisplayModeValidateAgainstDisplay: u32 = 0x00002000; 62 pub const kDisplayModeTelevisionFlag: u32 = 0x00100000; 63 pub const kDisplayModeValidForMirroringFlag: u32 = 0x00200000; 64 pub const kDisplayModeAcceleratorBackedFlag: u32 = 0x00400000; 65 pub const kDisplayModeValidForHiResFlag: u32 = 0x00800000; 66 pub const kDisplayModeValidForAirPlayFlag: u32 = 0x01000000; 67 pub const kDisplayModeNativeFlag: u32 = 0x02000000; 68 69 pub const kDisplayModeSafetyFlags: u32 = 0x00000007; 70 71 pub const IO1BitIndexedPixels: &str = "P"; 72 pub const IO2BitIndexedPixels: &str = "PP"; 73 pub const IO4BitIndexedPixels: &str = "PPPP"; 74 pub const IO8BitIndexedPixels: &str = "PPPPPPPP"; 75 pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB"; 76 pub const IO32BitDirectPixels: &str = "--------RRRRRRRRGGGGGGGGBBBBBBBB"; 77 pub const kIO30BitDirectPixels: &str = "--RRRRRRRRRRGGGGGGGGGGBBBBBBBBBB"; 78 pub const kIO64BitDirectPixels: &str = "-16R16G16B16"; 79 pub const kIO16BitFloatPixels: &str = "-16FR16FG16FB16"; 80 pub const kIO32BitFloatPixels: &str = "-32FR32FG32FB32"; 81 pub const IOYUV422Pixels: &str = "Y4U2V2"; 82 pub const IO8BitOverlayPixels: &str = "O8"; 83 84 85 pub use core_foundation::dictionary::{ CFDictionary, CFDictionaryRef, CFDictionaryGetValueIfPresent }; 86 pub use core_foundation::array::{ CFArray, CFArrayRef }; 87 pub use core_foundation::array::{ CFArrayGetCount, CFArrayGetValueAtIndex }; 88 pub use core_foundation::base::{ CFIndex, CFRelease, CFTypeRef }; 89 90 pub type CGDisplayConfigRef = *mut libc::c_void; 91 92 #[repr(u32)] 93 #[derive(Clone, Copy)] 94 pub enum CGConfigureOption { 95 ConfigureForAppOnly = 0, 96 ConfigureForSession = 1, 97 ConfigurePermanently = 2, 98 } 99 100 #[derive(Copy, Clone, Debug)] 101 pub struct CGDisplay { 102 pub id: CGDirectDisplayID, 103 } 104 105 foreign_type! { 106 #[doc(hidden)] 107 type CType = ::sys::CGDisplayMode; 108 fn drop = CGDisplayModeRelease; 109 fn clone = |p| CFRetain(p as *const _) as *mut _; 110 pub struct CGDisplayMode; 111 pub struct CGDisplayModeRef; 112 } 113 114 impl CGDisplay { 115 #[inline] new(id: CGDirectDisplayID) -> CGDisplay116 pub fn new(id: CGDirectDisplayID) -> CGDisplay { 117 CGDisplay { id: id } 118 } 119 120 /// Returns the the main display. 121 #[inline] main() -> CGDisplay122 pub fn main() -> CGDisplay { 123 CGDisplay::new(unsafe { CGMainDisplayID() }) 124 } 125 126 /// Returns the bounds of a display in the global display coordinate space. 127 #[inline] bounds(&self) -> CGRect128 pub fn bounds(&self) -> CGRect { 129 unsafe { CGDisplayBounds(self.id) } 130 } 131 132 /// Returns information about a display's current configuration. 133 #[inline] display_mode(&self) -> Option<CGDisplayMode>134 pub fn display_mode(&self) -> Option<CGDisplayMode> { 135 unsafe { 136 let mode_ref = CGDisplayCopyDisplayMode(self.id); 137 if !mode_ref.is_null() { 138 Some(CGDisplayMode::from_ptr(mode_ref)) 139 } else { 140 None 141 } 142 } 143 } 144 145 /// Begins a new set of display configuration changes. begin_configuration(&self) -> Result<CGDisplayConfigRef, CGError>146 pub fn begin_configuration(&self) -> Result<CGDisplayConfigRef, CGError> { 147 unsafe { 148 let mut config_ref: CGDisplayConfigRef = ptr::null_mut(); 149 let result = CGBeginDisplayConfiguration(&mut config_ref); 150 if result == 0 { 151 Ok(config_ref) 152 } else { 153 Err(result) 154 } 155 } 156 } 157 158 /// Cancels a set of display configuration changes. cancel_configuration(&self, config_ref: &CGDisplayConfigRef) -> Result<(), CGError>159 pub fn cancel_configuration(&self, config_ref: &CGDisplayConfigRef) -> Result<(), CGError> { 160 let result = unsafe { CGCancelDisplayConfiguration(*config_ref) }; 161 if result == 0 { 162 Ok(()) 163 } else { 164 Err(result) 165 } 166 } 167 168 /// Completes a set of display configuration changes. complete_configuration( &self, config_ref: &CGDisplayConfigRef, option: CGConfigureOption, ) -> Result<(), CGError>169 pub fn complete_configuration( 170 &self, 171 config_ref: &CGDisplayConfigRef, 172 option: CGConfigureOption, 173 ) -> Result<(), CGError> { 174 let result = unsafe { CGCompleteDisplayConfiguration(*config_ref, option) }; 175 if result == 0 { 176 Ok(()) 177 } else { 178 Err(result) 179 } 180 } 181 182 /// Configures the display mode of a display. configure_display_with_display_mode( &self, config_ref: &CGDisplayConfigRef, display_mode: &CGDisplayMode, ) -> Result<(), CGError>183 pub fn configure_display_with_display_mode( 184 &self, 185 config_ref: &CGDisplayConfigRef, 186 display_mode: &CGDisplayMode, 187 ) -> Result<(), CGError> { 188 let result = unsafe { 189 CGConfigureDisplayWithDisplayMode( 190 *config_ref, 191 self.id, 192 display_mode.as_ptr(), 193 ptr::null(), 194 ) 195 }; 196 if result == 0 { 197 Ok(()) 198 } else { 199 Err(result) 200 } 201 } 202 203 /// Returns an image containing the contents of the specified display. 204 #[inline] image(&self) -> Option<CGImage>205 pub fn image(&self) -> Option<CGImage> { 206 unsafe { 207 let image_ref = CGDisplayCreateImage(self.id); 208 if !image_ref.is_null() { 209 Some(CGImage::from_ptr(image_ref)) 210 } else { 211 None 212 } 213 } 214 } 215 216 /// Returns a composite image based on a dynamically generated list of 217 /// windows. 218 #[inline] screenshot( bounds: CGRect, list_option: CGWindowListOption, window_id: CGWindowID, image_option: CGWindowImageOption, ) -> Option<CGImage>219 pub fn screenshot( 220 bounds: CGRect, 221 list_option: CGWindowListOption, 222 window_id: CGWindowID, 223 image_option: CGWindowImageOption, 224 ) -> Option<CGImage> { 225 unsafe { 226 let image_ref = CGWindowListCreateImage(bounds, list_option, window_id, image_option); 227 if !image_ref.is_null() { 228 Some(CGImage::from_ptr(image_ref)) 229 } else { 230 None 231 } 232 } 233 } 234 235 /// Returns a composite image of the specified windows. 236 #[inline] screenshot_from_windows( bounds: CGRect, windows: CFArray, image_option: CGWindowImageOption, ) -> Option<CGImage>237 pub fn screenshot_from_windows( 238 bounds: CGRect, 239 windows: CFArray, 240 image_option: CGWindowImageOption, 241 ) -> Option<CGImage> { 242 unsafe { 243 let image_ref = CGWindowListCreateImageFromArray( 244 bounds, 245 windows.as_concrete_TypeRef(), 246 image_option, 247 ); 248 if !image_ref.is_null() { 249 Some(CGImage::from_ptr(image_ref)) 250 } else { 251 None 252 } 253 } 254 } 255 256 /// Generates and returns information about the selected windows in the 257 /// current user session. window_list_info( option: CGWindowListOption, relative_to_window: Option<CGWindowID>, ) -> Option<CFArray>258 pub fn window_list_info( 259 option: CGWindowListOption, 260 relative_to_window: Option<CGWindowID>, 261 ) -> Option<CFArray> { 262 let relative_to_window = relative_to_window.unwrap_or(kCGNullWindowID); 263 let array_ref = unsafe { CGWindowListCopyWindowInfo(option, relative_to_window) }; 264 if array_ref != ptr::null() { 265 Some(unsafe { TCFType::wrap_under_create_rule(array_ref) }) 266 } else { 267 None 268 } 269 } 270 271 /// Returns a Boolean value indicating whether a display is active. 272 #[inline] is_active(&self) -> bool273 pub fn is_active(&self) -> bool { 274 unsafe { CGDisplayIsActive(self.id) != 0 } 275 } 276 277 /// Returns a boolean indicating whether a display is always in a 278 /// mirroring set. 279 #[inline] is_always_in_mirror_set(&self) -> bool280 pub fn is_always_in_mirror_set(&self) -> bool { 281 unsafe { CGDisplayIsAlwaysInMirrorSet(self.id) != 0 } 282 } 283 284 /// Returns a boolean indicating whether a display is sleeping (and is 285 /// therefore not drawable.) 286 #[inline] is_asleep(&self) -> bool287 pub fn is_asleep(&self) -> bool { 288 unsafe { CGDisplayIsAsleep(self.id) != 0 } 289 } 290 291 /// Returns a boolean indicating whether a display is built-in, such as 292 /// the internal display in portable systems. 293 #[inline] is_builtin(&self) -> bool294 pub fn is_builtin(&self) -> bool { 295 unsafe { CGDisplayIsBuiltin(self.id) != 0 } 296 } 297 298 /// Returns a boolean indicating whether a display is in a hardware 299 /// mirroring set. 300 #[inline] is_in_hw_mirror_set(&self) -> bool301 pub fn is_in_hw_mirror_set(&self) -> bool { 302 unsafe { CGDisplayIsInHWMirrorSet(self.id) != 0 } 303 } 304 305 /// Returns a boolean indicating whether a display is in a mirroring set. 306 #[inline] is_in_mirror_set(&self) -> bool307 pub fn is_in_mirror_set(&self) -> bool { 308 unsafe { CGDisplayIsInMirrorSet(self.id) != 0 } 309 } 310 311 /// Returns a boolean indicating whether a display is the main display. 312 #[inline] is_main(&self) -> bool313 pub fn is_main(&self) -> bool { 314 unsafe { CGDisplayIsMain(self.id) != 0 } 315 } 316 317 /// Returns a boolean indicating whether a display is connected or online. 318 #[inline] is_online(&self) -> bool319 pub fn is_online(&self) -> bool { 320 unsafe { CGDisplayIsOnline(self.id) != 0 } 321 } 322 323 /// Returns a boolean indicating whether Quartz is using OpenGL-based 324 /// window acceleration (Quartz Extreme) to render in a display. 325 #[inline] uses_open_gl_acceleration(&self) -> bool326 pub fn uses_open_gl_acceleration(&self) -> bool { 327 unsafe { CGDisplayUsesOpenGLAcceleration(self.id) != 0 } 328 } 329 330 /// Returns a boolean indicating whether a display is running in a stereo 331 /// graphics mode. 332 #[inline] is_stereo(&self) -> bool333 pub fn is_stereo(&self) -> bool { 334 unsafe { CGDisplayIsStereo(self.id) != 0 } 335 } 336 337 /// For a secondary display in a mirroring set, returns the primary 338 /// display. 339 #[inline] mirrors_display(&self) -> CGDirectDisplayID340 pub fn mirrors_display(&self) -> CGDirectDisplayID { 341 unsafe { CGDisplayMirrorsDisplay(self.id) } 342 } 343 344 /// Returns the primary display in a hardware mirroring set. 345 #[inline] primary_display(&self) -> CGDirectDisplayID346 pub fn primary_display(&self) -> CGDirectDisplayID { 347 unsafe { CGDisplayPrimaryDisplay(self.id) } 348 } 349 350 /// Returns the rotation angle of a display in degrees. 351 #[inline] rotation(&self) -> f64352 pub fn rotation(&self) -> f64 { 353 unsafe { CGDisplayRotation(self.id) } 354 } 355 356 /// Returns the width and height of a display in millimeters. 357 #[inline] screen_size(&self) -> CGSize358 pub fn screen_size(&self) -> CGSize { 359 unsafe { CGDisplayScreenSize(self.id) } 360 } 361 362 /// Returns the serial number of a display monitor. 363 #[inline] serial_number(&self) -> u32364 pub fn serial_number(&self) -> u32 { 365 unsafe { CGDisplaySerialNumber(self.id) } 366 } 367 368 /// Returns the logical unit number of a display. 369 #[inline] unit_number(&self) -> u32370 pub fn unit_number(&self) -> u32 { 371 unsafe { CGDisplayUnitNumber(self.id) } 372 } 373 374 /// Returns the vendor number of the specified display's monitor. 375 #[inline] vendor_number(&self) -> u32376 pub fn vendor_number(&self) -> u32 { 377 unsafe { CGDisplayVendorNumber(self.id) } 378 } 379 380 /// Returns the model number of a display monitor. 381 #[inline] model_number(&self) -> u32382 pub fn model_number(&self) -> u32 { 383 unsafe { CGDisplayModelNumber(self.id) } 384 } 385 386 /// Returns the display height in pixel units. 387 #[inline] pixels_high(&self) -> u64388 pub fn pixels_high(&self) -> u64 { 389 unsafe { CGDisplayPixelsHigh(self.id) as u64 } 390 } 391 392 /// Returns the display width in pixel units. 393 #[inline] pixels_wide(&self) -> u64394 pub fn pixels_wide(&self) -> u64 { 395 unsafe { CGDisplayPixelsWide(self.id) as u64 } 396 } 397 398 /// Provides a list of displays that are active (or drawable). 399 #[inline] active_displays() -> Result<Vec<CGDirectDisplayID>, CGError>400 pub fn active_displays() -> Result<Vec<CGDirectDisplayID>, CGError> { 401 let count = try!(CGDisplay::active_display_count()); 402 let mut buf: Vec<CGDirectDisplayID> = vec![0; count as usize]; 403 let result = 404 unsafe { CGGetActiveDisplayList(count as u32, buf.as_mut_ptr(), ptr::null_mut()) }; 405 if result == 0 { 406 Ok(buf) 407 } else { 408 Err(result) 409 } 410 } 411 412 /// Provides count of displays that are active (or drawable). 413 #[inline] active_display_count() -> Result<u32, CGError>414 pub fn active_display_count() -> Result<u32, CGError> { 415 let mut count: libc::uint32_t = 0; 416 let result = unsafe { CGGetActiveDisplayList(0, ptr::null_mut(), &mut count) }; 417 if result == 0 { 418 Ok(count as u32) 419 } else { 420 Err(result) 421 } 422 } 423 424 /// Hides the mouse cursor, and increments the hide cursor count. 425 #[inline] hide_cursor(&self) -> Result<(), CGError>426 pub fn hide_cursor(&self) -> Result<(), CGError> { 427 let result = unsafe { CGDisplayHideCursor(self.id) }; 428 if result == 0 { 429 Ok(()) 430 } else { 431 Err(result) 432 } 433 } 434 435 /// Decrements the hide cursor count, and shows the mouse cursor if the 436 /// count is 0. 437 #[inline] show_cursor(&self) -> Result<(), CGError>438 pub fn show_cursor(&self) -> Result<(), CGError> { 439 let result = unsafe { CGDisplayShowCursor(self.id) }; 440 if result == 0 { 441 Ok(()) 442 } else { 443 Err(result) 444 } 445 } 446 447 /// Moves the mouse cursor to a specified point relative to the display 448 /// origin (the upper-left corner of the display). 449 #[inline] move_cursor_to_point(&self, point: CGPoint) -> Result<(), CGError>450 pub fn move_cursor_to_point(&self, point: CGPoint) -> Result<(), CGError> { 451 let result = unsafe { CGDisplayMoveCursorToPoint(self.id, point) }; 452 if result == 0 { 453 Ok(()) 454 } else { 455 Err(result) 456 } 457 } 458 459 /// Moves the mouse cursor without generating events. 460 #[inline] warp_mouse_cursor_position(point: CGPoint) -> Result<(), CGError>461 pub fn warp_mouse_cursor_position(point: CGPoint) -> Result<(), CGError> { 462 let result = unsafe { CGWarpMouseCursorPosition(point) }; 463 if result == 0 { 464 Ok(()) 465 } else { 466 Err(result) 467 } 468 } 469 470 /// Connects or disconnects the mouse and cursor while an application is 471 /// in the foreground. 472 #[inline] associate_mouse_and_mouse_cursor_position(connected: bool) -> Result<(), CGError>473 pub fn associate_mouse_and_mouse_cursor_position(connected: bool) -> Result<(), CGError> { 474 let result = unsafe { CGAssociateMouseAndMouseCursorPosition(connected as boolean_t) }; 475 if result == 0 { 476 Ok(()) 477 } else { 478 Err(result) 479 } 480 } 481 } 482 483 impl CGDisplayMode { 484 /// Returns all display modes for the specified display id. all_display_modes( display_id: CGDirectDisplayID, options: CFDictionaryRef, ) -> Option<Vec<CGDisplayMode>>485 pub fn all_display_modes( 486 display_id: CGDirectDisplayID, 487 options: CFDictionaryRef, 488 ) -> Option<Vec<CGDisplayMode>> { 489 let array_opt: Option<CFArray> = unsafe { 490 let array_ref = CGDisplayCopyAllDisplayModes(display_id, options); 491 if array_ref != ptr::null() { 492 Some(CFArray::wrap_under_create_rule(array_ref)) 493 } else { 494 None 495 } 496 }; 497 match array_opt { 498 Some(modes) => { 499 let vec: Vec<CGDisplayMode> = modes 500 .into_iter() 501 .map(|value0| { 502 let x = *value0.deref() as *mut ::sys::CGDisplayMode; 503 unsafe { CGDisplayMode::from_ptr(x) } 504 }).collect(); 505 Some(vec) 506 } 507 None => None, 508 } 509 } 510 511 /// Returns the height of the specified display mode. 512 #[inline] height(&self) -> u64513 pub fn height(&self) -> u64 { 514 unsafe { CGDisplayModeGetHeight(self.as_ptr()) as u64 } 515 } 516 517 /// Returns the width of the specified display mode. 518 #[inline] width(&self) -> u64519 pub fn width(&self) -> u64 { 520 unsafe { CGDisplayModeGetWidth(self.as_ptr()) as u64 } 521 } 522 523 /// Returns the pixel height of the specified display mode. 524 #[inline] pixel_height(&self) -> u64525 pub fn pixel_height(&self) -> u64 { 526 unsafe { CGDisplayModeGetPixelHeight(self.as_ptr()) as u64 } 527 } 528 529 /// Returns the pixel width of the specified display mode. 530 #[inline] pixel_width(&self) -> u64531 pub fn pixel_width(&self) -> u64 { 532 unsafe { CGDisplayModeGetPixelWidth(self.as_ptr()) as u64 } 533 } 534 535 #[inline] refresh_rate(&self) -> f64536 pub fn refresh_rate(&self) -> f64 { 537 unsafe { CGDisplayModeGetRefreshRate(self.as_ptr()) } 538 } 539 540 /// Returns the I/O Kit flags of the specified display mode. 541 #[inline] io_flags(&self) -> u32542 pub fn io_flags(&self) -> u32 { 543 unsafe { CGDisplayModeGetIOFlags(self.as_ptr()) as u32 } 544 } 545 546 /// Returns the pixel encoding of the specified display mode. 547 #[inline] pixel_encoding(&self) -> CFString548 pub fn pixel_encoding(&self) -> CFString { 549 unsafe { CFString::wrap_under_create_rule(CGDisplayModeCopyPixelEncoding(self.as_ptr())) } 550 } 551 552 /// Returns the number of bits per pixel of the specified display mode. bit_depth(&self) -> usize553 pub fn bit_depth(&self) -> usize { 554 let pixel_encoding = self.pixel_encoding().to_string(); 555 // my numerical representation for kIO16BitFloatPixels and kIO32bitFloatPixels 556 // are made up and possibly non-sensical 557 if pixel_encoding.eq_ignore_ascii_case(kIO32BitFloatPixels) { 558 96 559 } else if pixel_encoding.eq_ignore_ascii_case(kIO64BitDirectPixels) { 560 64 561 } else if pixel_encoding.eq_ignore_ascii_case(kIO16BitFloatPixels) { 562 48 563 } else if pixel_encoding.eq_ignore_ascii_case(IO32BitDirectPixels) { 564 32 565 } else if pixel_encoding.eq_ignore_ascii_case(kIO30BitDirectPixels) { 566 30 567 } else if pixel_encoding.eq_ignore_ascii_case(IO16BitDirectPixels) { 568 16 569 } else if pixel_encoding.eq_ignore_ascii_case(IO8BitIndexedPixels) { 570 8 571 }else{ 572 0 573 } 574 } 575 } 576 577 #[link(name = "CoreGraphics", kind = "framework")] 578 extern "C" { 579 pub static CGRectNull: CGRect; 580 pub static CGRectInfinite: CGRect; 581 582 pub static kCGDisplayShowDuplicateLowResolutionModes: CFStringRef; 583 CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef)584 pub fn CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef); 585 CGMainDisplayID() -> CGDirectDisplayID586 pub fn CGMainDisplayID() -> CGDirectDisplayID; CGDisplayIsActive(display: CGDirectDisplayID) -> boolean_t587 pub fn CGDisplayIsActive(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsAlwaysInMirrorSet(display: CGDirectDisplayID) -> boolean_t588 pub fn CGDisplayIsAlwaysInMirrorSet(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsAsleep(display: CGDirectDisplayID) -> boolean_t589 pub fn CGDisplayIsAsleep(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsBuiltin(display: CGDirectDisplayID) -> boolean_t590 pub fn CGDisplayIsBuiltin(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsInHWMirrorSet(display: CGDirectDisplayID) -> boolean_t591 pub fn CGDisplayIsInHWMirrorSet(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsInMirrorSet(display: CGDirectDisplayID) -> boolean_t592 pub fn CGDisplayIsInMirrorSet(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsMain(display: CGDirectDisplayID) -> boolean_t593 pub fn CGDisplayIsMain(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsOnline(display: CGDirectDisplayID) -> boolean_t594 pub fn CGDisplayIsOnline(display: CGDirectDisplayID) -> boolean_t; CGDisplayIsStereo(display: CGDirectDisplayID) -> boolean_t595 pub fn CGDisplayIsStereo(display: CGDirectDisplayID) -> boolean_t; CGDisplayMirrorsDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID596 pub fn CGDisplayMirrorsDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; CGDisplayPrimaryDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID597 pub fn CGDisplayPrimaryDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID; CGDisplayRotation(display: CGDirectDisplayID) -> libc::c_double598 pub fn CGDisplayRotation(display: CGDirectDisplayID) -> libc::c_double; CGDisplayScreenSize(display: CGDirectDisplayID) -> CGSize599 pub fn CGDisplayScreenSize(display: CGDirectDisplayID) -> CGSize; CGDisplaySerialNumber(display: CGDirectDisplayID) -> libc::uint32_t600 pub fn CGDisplaySerialNumber(display: CGDirectDisplayID) -> libc::uint32_t; CGDisplayUnitNumber(display: CGDirectDisplayID) -> libc::uint32_t601 pub fn CGDisplayUnitNumber(display: CGDirectDisplayID) -> libc::uint32_t; CGDisplayUsesOpenGLAcceleration(display: CGDirectDisplayID) -> boolean_t602 pub fn CGDisplayUsesOpenGLAcceleration(display: CGDirectDisplayID) -> boolean_t; CGDisplayVendorNumber(display: CGDirectDisplayID) -> libc::uint32_t603 pub fn CGDisplayVendorNumber(display: CGDirectDisplayID) -> libc::uint32_t; CGGetActiveDisplayList( max_displays: libc::uint32_t, active_displays: *mut CGDirectDisplayID, display_count: *mut libc::uint32_t, ) -> CGError604 pub fn CGGetActiveDisplayList( 605 max_displays: libc::uint32_t, 606 active_displays: *mut CGDirectDisplayID, 607 display_count: *mut libc::uint32_t, 608 ) -> CGError; CGGetDisplaysWithRect( rect: CGRect, max_displays: libc::uint32_t, displays: *mut CGDirectDisplayID, matching_display_count: *mut libc::uint32_t, ) -> CGError609 pub fn CGGetDisplaysWithRect( 610 rect: CGRect, 611 max_displays: libc::uint32_t, 612 displays: *mut CGDirectDisplayID, 613 matching_display_count: *mut libc::uint32_t, 614 ) -> CGError; CGDisplayModelNumber(display: CGDirectDisplayID) -> libc::uint32_t615 pub fn CGDisplayModelNumber(display: CGDirectDisplayID) -> libc::uint32_t; CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t616 pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t; CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t617 pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t; CGDisplayBounds(display: CGDirectDisplayID) -> CGRect618 pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect; CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef619 pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef; 620 CGBeginDisplayConfiguration(config: *const CGDisplayConfigRef) -> CGError621 pub fn CGBeginDisplayConfiguration(config: *const CGDisplayConfigRef) -> CGError; CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError622 pub fn CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError; CGCompleteDisplayConfiguration( config: CGDisplayConfigRef, option: CGConfigureOption, ) -> CGError623 pub fn CGCompleteDisplayConfiguration( 624 config: CGDisplayConfigRef, 625 option: CGConfigureOption, 626 ) -> CGError; CGConfigureDisplayWithDisplayMode( config: CGDisplayConfigRef, display: CGDirectDisplayID, mode: ::sys::CGDisplayModeRef, options: CFDictionaryRef, ) -> CGError627 pub fn CGConfigureDisplayWithDisplayMode( 628 config: CGDisplayConfigRef, 629 display: CGDirectDisplayID, 630 mode: ::sys::CGDisplayModeRef, 631 options: CFDictionaryRef, 632 ) -> CGError; 633 CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef634 pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef; CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t635 pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t; CGDisplayModeGetWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t636 pub fn CGDisplayModeGetWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t; CGDisplayModeGetPixelHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t637 pub fn CGDisplayModeGetPixelHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t; CGDisplayModeGetPixelWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t638 pub fn CGDisplayModeGetPixelWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t; CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double639 pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double; CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> libc::uint32_t640 pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> libc::uint32_t; CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef641 pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef; 642 CGDisplayCopyAllDisplayModes( display: CGDirectDisplayID, options: CFDictionaryRef, ) -> CFArrayRef643 pub fn CGDisplayCopyAllDisplayModes( 644 display: CGDirectDisplayID, 645 options: CFDictionaryRef, 646 ) -> CFArrayRef; 647 648 // mouse stuff CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError649 pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError; CGDisplayShowCursor(display: CGDirectDisplayID) -> CGError650 pub fn CGDisplayShowCursor(display: CGDirectDisplayID) -> CGError; CGDisplayMoveCursorToPoint(display: CGDirectDisplayID, point: CGPoint) -> CGError651 pub fn CGDisplayMoveCursorToPoint(display: CGDirectDisplayID, point: CGPoint) -> CGError; CGWarpMouseCursorPosition(point: CGPoint) -> CGError652 pub fn CGWarpMouseCursorPosition(point: CGPoint) -> CGError; CGAssociateMouseAndMouseCursorPosition(connected: boolean_t) -> CGError653 pub fn CGAssociateMouseAndMouseCursorPosition(connected: boolean_t) -> CGError; 654 655 // Window Services Reference CGWindowListCopyWindowInfo( option: CGWindowListOption, relativeToWindow: CGWindowID, ) -> CFArrayRef656 pub fn CGWindowListCopyWindowInfo( 657 option: CGWindowListOption, 658 relativeToWindow: CGWindowID, 659 ) -> CFArrayRef; CGWindowListCreateImage( screenBounds: CGRect, listOptions: CGWindowListOption, windowId: CGWindowID, imageOptions: CGWindowImageOption, ) -> ::sys::CGImageRef660 pub fn CGWindowListCreateImage( 661 screenBounds: CGRect, 662 listOptions: CGWindowListOption, 663 windowId: CGWindowID, 664 imageOptions: CGWindowImageOption, 665 ) -> ::sys::CGImageRef; CGWindowListCreateImageFromArray( screenBounds: CGRect, windowArray: CFArrayRef, imageOptions: CGWindowImageOption, ) -> ::sys::CGImageRef666 pub fn CGWindowListCreateImageFromArray( 667 screenBounds: CGRect, 668 windowArray: CFArrayRef, 669 imageOptions: CGWindowImageOption, 670 ) -> ::sys::CGImageRef; 671 } 672