Debian Codegraph @

third_party/rust/core-graphics/src/display.rs

raw
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 = u32;
25 pub type CGWindowID = u32;
26 pub type CGWindowLevel = i32;
27
28 pub const kCGNullWindowID: CGWindowID = 0 as CGWindowID;
29 pub const kCGNullDirectDisplayID: CGDirectDisplayID = 0 as CGDirectDisplayID;
30
31 pub type CGWindowListOption = u32;
32
33 pub const kCGWindowListOptionAll: CGWindowListOption = 0;
34 pub const kCGWindowListOptionOnScreenOnly: CGWindowListOption = 1 << 0;
35 pub const kCGWindowListOptionOnScreenAboveWindow: CGWindowListOption = 1 << 1;
36 pub const kCGWindowListOptionOnScreenBelowWindow: CGWindowListOption = 1 << 2;
37 pub const kCGWindowListOptionIncludingWindow: CGWindowListOption = 1 << 3;
38 pub const kCGWindowListExcludeDesktopElements: CGWindowListOption = 1 << 4;
39
40 pub type CGWindowImageOption = u32;
41
42 pub const kCGWindowImageDefault: CGWindowImageOption = 0;
43 pub const kCGWindowImageBoundsIgnoreFraming: CGWindowImageOption = 1 << 0;
44 pub const kCGWindowImageShouldBeOpaque: CGWindowImageOption = 1 << 1;
45 pub const kCGWindowImageOnlyShadows: CGWindowImageOption = 1 << 2;
46 pub const kCGWindowImageBestResolution: CGWindowImageOption = 1 << 3;
47 pub const kCGWindowImageNominalResolution: CGWindowImageOption = 1 << 4;
48
49 pub const kDisplayModeValidFlag: u32 = 0x00000001;
50 pub const kDisplayModeSafeFlag: u32 = 0x00000002;
51 pub const kDisplayModeDefaultFlag: u32 = 0x00000004;
52 pub const kDisplayModeAlwaysShowFlag: u32 = 0x00000008;
53 pub const kDisplayModeNeverShowFlag: u32 = 0x00000080;
54 pub const kDisplayModeNotResizeFlag: u32 = 0x00000010;
55 pub const kDisplayModeRequiresPanFlag: u32 = 0x00000020;
56 pub const kDisplayModeInterlacedFlag: u32 = 0x00000040;
57 pub const kDisplayModeSimulscanFlag: u32 = 0x00000100;
58 pub const kDisplayModeBuiltInFlag: u32 = 0x00000400;
59 pub const kDisplayModeNotPresetFlag: u32 = 0x00000200;
60 pub const kDisplayModeStretchedFlag: u32 = 0x00000800;
61 pub const kDisplayModeNotGraphicsQualityFlag: u32 = 0x00001000;
62 pub const kDisplayModeValidateAgainstDisplay: u32 = 0x00002000;
63 pub const kDisplayModeTelevisionFlag: u32 = 0x00100000;
64 pub const kDisplayModeValidForMirroringFlag: u32 = 0x00200000;
65 pub const kDisplayModeAcceleratorBackedFlag: u32 = 0x00400000;
66 pub const kDisplayModeValidForHiResFlag: u32 = 0x00800000;
67 pub const kDisplayModeValidForAirPlayFlag: u32 = 0x01000000;
68 pub const kDisplayModeNativeFlag: u32 = 0x02000000;
69
70 pub const kDisplayModeSafetyFlags: u32 = 0x00000007;
71
72 pub type CGDisplayBlendFraction = f32;
73 pub const kCGDisplayBlendNormal: CGDisplayBlendFraction = 0.0;
74 pub const kCGDisplayBlendSolidColor: CGDisplayBlendFraction = 1.0;
75
76 pub type CGDisplayFadeReservationToken = u32;
77 pub const kCGDisplayFadeReservationInvalidToken: CGDisplayFadeReservationToken = 0;
78
79 pub type CGDisplayFadeInterval = f32;
80 pub type CGDisplayReservationInterval = f32;
81 pub const kCGMaxDisplayReservationInterval: CGDisplayReservationInterval = 15.0;
82
83 pub const IO1BitIndexedPixels: &str = "P";
84 pub const IO2BitIndexedPixels: &str = "PP";
85 pub const IO4BitIndexedPixels: &str = "PPPP";
86 pub const IO8BitIndexedPixels: &str = "PPPPPPPP";
87 pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB";
88 pub const IO32BitDirectPixels: &str = "--------RRRRRRRRGGGGGGGGBBBBBBBB";
89 pub const kIO30BitDirectPixels: &str = "--RRRRRRRRRRGGGGGGGGGGBBBBBBBBBB";
90 pub const kIO64BitDirectPixels: &str = "-16R16G16B16";
91 pub const kIO16BitFloatPixels: &str = "-16FR16FG16FB16";
92 pub const kIO32BitFloatPixels: &str = "-32FR32FG32FB32";
93 pub const IOYUV422Pixels: &str = "Y4U2V2";
94 pub const IO8BitOverlayPixels: &str = "O8";
95
96
97 pub use core_foundation::dictionary::{ CFDictionary, CFDictionaryRef, CFDictionaryGetValueIfPresent };
98 pub use core_foundation::array::{ CFArray, CFArrayRef };
99 pub use core_foundation::array::{ CFArrayGetCount, CFArrayGetValueAtIndex };
100 pub use core_foundation::base::{ CFIndex, CFRelease, CFTypeRef };
101
102 pub type CGDisplayConfigRef = *mut libc::c_void;
103
104 #[repr(u32)]
105 #[derive(Clone, Copy)]
106 pub enum CGConfigureOption {
107 ConfigureForAppOnly = 0,
108 ConfigureForSession = 1,
109 ConfigurePermanently = 2,
110 }
111
112 #[derive(Copy, Clone, Debug)]
113 pub struct CGDisplay {
114 pub id: CGDirectDisplayID,
115 }
116
117 foreign_type! {
118 #[doc(hidden)]
119 pub unsafe type CGDisplayMode {
120 type CType = ::sys::CGDisplayMode;
121 fn drop = CGDisplayModeRelease;
122 fn clone = |p| CFRetain(p as *const _) as *mut _;
123 }
124 }
125
126 impl CGDisplay {
127 #[inline]
128 pub fn new(id: CGDirectDisplayID) -> CGDisplay {
129 CGDisplay { id: id }
130 }
131
132 /// Returns the the main display.
133 #[inline]
134 pub fn main() -> CGDisplay {
135 CGDisplay::new(unsafe { CGMainDisplayID() })
136 }
137
138 /// A value that will never correspond to actual hardware.
139 pub fn null_display() -> CGDisplay {
140 CGDisplay::new(kCGNullDirectDisplayID)
141 }
142
143 /// Returns the bounds of a display in the global display coordinate space.
144 #[inline]
145 pub fn bounds(&self) -> CGRect {
146 unsafe { CGDisplayBounds(self.id) }
147 }
148
149 /// Returns information about a display's current configuration.
150 #[inline]
151 pub fn display_mode(&self) -> Option<CGDisplayMode> {
152 unsafe {
153 let mode_ref = CGDisplayCopyDisplayMode(self.id);
154 if !mode_ref.is_null() {
155 Some(CGDisplayMode::from_ptr(mode_ref))
156 } else {
157 None
158 }
159 }
160 }
161
162 /// Begins a new set of display configuration changes.
163 pub fn begin_configuration(&self) -> Result<CGDisplayConfigRef, CGError> {
164 unsafe {
165 let mut config_ref: CGDisplayConfigRef = ptr::null_mut();
166 let result = CGBeginDisplayConfiguration(&mut config_ref);
167 if result == 0 {
168 Ok(config_ref)
169 } else {
170 Err(result)
171 }
172 }
173 }
174
175 /// Cancels a set of display configuration changes.
176 pub fn cancel_configuration(&self, config_ref: &CGDisplayConfigRef) -> Result<(), CGError> {
177 let result = unsafe { CGCancelDisplayConfiguration(*config_ref) };
178 if result == 0 {
179 Ok(())
180 } else {
181 Err(result)
182 }
183 }
184
185 /// Completes a set of display configuration changes.
186 pub fn complete_configuration(
187 &self,
188 config_ref: &CGDisplayConfigRef,
189 option: CGConfigureOption,
190 ) -> Result<(), CGError> {
191 let result = unsafe { CGCompleteDisplayConfiguration(*config_ref, option) };
192 if result == 0 {
193 Ok(())
194 } else {
195 Err(result)
196 }
197 }
198
199 /// Configures the display mode of a display.
200 pub fn configure_display_with_display_mode(
201 &self,
202 config_ref: &CGDisplayConfigRef,
203 display_mode: &CGDisplayMode,
204 ) -> Result<(), CGError> {
205 let result = unsafe {
206 CGConfigureDisplayWithDisplayMode(
207 *config_ref,
208 self.id,
209 display_mode.as_ptr(),
210 ptr::null(),
211 )
212 };
213 if result == 0 {
214 Ok(())
215 } else {
216 Err(result)
217 }
218 }
219
220 /// Configures the origin of a display in the global display coordinate space.
221 pub fn configure_display_origin(
222 &self,
223 config_ref: &CGDisplayConfigRef,
224 x: i32,
225 y: i32,
226 ) -> Result<(), CGError> {
227 let result = unsafe { CGConfigureDisplayOrigin(*config_ref, self.id, x, y) };
228
229 if result == 0 {
230 Ok(())
231 } else {
232 Err(result)
233 }
234 }
235
236 /// Changes the configuration of a mirroring set.
237 pub fn configure_display_mirror_of_display(
238 &self,
239 config_ref: &CGDisplayConfigRef,
240 master: &CGDisplay,
241 ) -> Result<(), CGError> {
242 let result = unsafe { CGConfigureDisplayMirrorOfDisplay(*config_ref, self.id, master.id) };
243
244 if result == 0 {
245 Ok(())
246 } else {
247 Err(result)
248 }
249 }
250
251 /// Returns an image containing the contents of the specified display.
252 #[inline]
253 pub fn image(&self) -> Option<CGImage> {
254 unsafe {
255 let image_ref = CGDisplayCreateImage(self.id);
256 if !image_ref.is_null() {
257 Some(CGImage::from_ptr(image_ref))
258 } else {
259 None
260 }
261 }
262 }
263
264 /// Returns an image containing the contents of a portion of the specified display.
265 #[inline]
266 pub fn image_for_rect(&self, bounds: CGRect) -> Option<CGImage> {
267 unsafe {
268 let image_ref = CGDisplayCreateImageForRect(self.id, bounds);
269 if !image_ref.is_null() {
270 Some(CGImage::from_ptr(image_ref))
271 } else {
272 None
273 }
274 }
275 }
276
277 /// Returns a composite image based on a dynamically generated list of
278 /// windows.
279 #[inline]
280 pub fn screenshot(
281 bounds: CGRect,
282 list_option: CGWindowListOption,
283 window_id: CGWindowID,
284 image_option: CGWindowImageOption,
285 ) -> Option<CGImage> {
286 unsafe {
287 let image_ref = CGWindowListCreateImage(bounds, list_option, window_id, image_option);
288 if !image_ref.is_null() {
289 Some(CGImage::from_ptr(image_ref))
290 } else {
291 None
292 }
293 }
294 }
295
296 /// Returns a composite image of the specified windows.
297 #[inline]
298 pub fn screenshot_from_windows(
299 bounds: CGRect,
300 windows: CFArray,
301 image_option: CGWindowImageOption,
302 ) -> Option<CGImage> {
303 unsafe {
304 let image_ref = CGWindowListCreateImageFromArray(
305 bounds,
306 windows.as_concrete_TypeRef(),
307 image_option,
308 );
309 if !image_ref.is_null() {
310 Some(CGImage::from_ptr(image_ref))
311 } else {
312 None
313 }
314 }
315 }
316
317 /// Generates and returns information about the selected windows in the
318 /// current user session.
319 pub fn window_list_info(
320 option: CGWindowListOption,
321 relative_to_window: Option<CGWindowID>,
322 ) -> Option<CFArray> {
323 let relative_to_window = relative_to_window.unwrap_or(kCGNullWindowID);
324 let array_ref = unsafe { CGWindowListCopyWindowInfo(option, relative_to_window) };
325 if !array_ref.is_null() {
326 Some(unsafe { TCFType::wrap_under_create_rule(array_ref) })
327 } else {
328 None
329 }
330 }
331
332 /// Returns a Boolean value indicating whether a display is active.
333 #[inline]
334 pub fn is_active(&self) -> bool {
335 unsafe { CGDisplayIsActive(self.id) != 0 }
336 }
337
338 /// Returns a boolean indicating whether a display is always in a
339 /// mirroring set.
340 #[inline]
341 pub fn is_always_in_mirror_set(&self) -> bool {
342 unsafe { CGDisplayIsAlwaysInMirrorSet(self.id) != 0 }
343 }
344
345 /// Returns a boolean indicating whether a display is sleeping (and is
346 /// therefore not drawable.)
347 #[inline]
348 pub fn is_asleep(&self) -> bool {
349 unsafe { CGDisplayIsAsleep(self.id) != 0 }
350 }
351
352 /// Returns a boolean indicating whether a display is built-in, such as
353 /// the internal display in portable systems.
354 #[inline]
355 pub fn is_builtin(&self) -> bool {
356 unsafe { CGDisplayIsBuiltin(self.id) != 0 }
357 }
358
359 /// Returns a boolean indicating whether a display is in a hardware
360 /// mirroring set.
361 #[inline]
362 pub fn is_in_hw_mirror_set(&self) -> bool {
363 unsafe { CGDisplayIsInHWMirrorSet(self.id) != 0 }
364 }
365
366 /// Returns a boolean indicating whether a display is in a mirroring set.
367 #[inline]
368 pub fn is_in_mirror_set(&self) -> bool {
369 unsafe { CGDisplayIsInMirrorSet(self.id) != 0 }
370 }
371
372 /// Returns a boolean indicating whether a display is the main display.
373 #[inline]
374 pub fn is_main(&self) -> bool {
375 unsafe { CGDisplayIsMain(self.id) != 0 }
376 }
377
378 /// Returns a boolean indicating whether a display is connected or online.
379 #[inline]
380 pub fn is_online(&self) -> bool {
381 unsafe { CGDisplayIsOnline(self.id) != 0 }
382 }
383
384 /// Returns a boolean indicating whether Quartz is using OpenGL-based
385 /// window acceleration (Quartz Extreme) to render in a display.
386 #[inline]
387 pub fn uses_open_gl_acceleration(&self) -> bool {
388 unsafe { CGDisplayUsesOpenGLAcceleration(self.id) != 0 }
389 }
390
391 /// Returns a boolean indicating whether a display is running in a stereo
392 /// graphics mode.
393 #[inline]
394 pub fn is_stereo(&self) -> bool {
395 unsafe { CGDisplayIsStereo(self.id) != 0 }
396 }
397
398 /// For a secondary display in a mirroring set, returns the primary
399 /// display.
400 #[inline]
401 pub fn mirrors_display(&self) -> CGDirectDisplayID {
402 unsafe { CGDisplayMirrorsDisplay(self.id) }
403 }
404
405 /// Returns the primary display in a hardware mirroring set.
406 #[inline]
407 pub fn primary_display(&self) -> CGDirectDisplayID {
408 unsafe { CGDisplayPrimaryDisplay(self.id) }
409 }
410
411 /// Returns the rotation angle of a display in degrees.
412 #[inline]
413 pub fn rotation(&self) -> f64 {
414 unsafe { CGDisplayRotation(self.id) }
415 }
416
417 /// Returns the width and height of a display in millimeters.
418 #[inline]
419 pub fn screen_size(&self) -> CGSize {
420 unsafe { CGDisplayScreenSize(self.id) }
421 }
422
423 /// Returns the serial number of a display monitor.
424 #[inline]
425 pub fn serial_number(&self) -> u32 {
426 unsafe { CGDisplaySerialNumber(self.id) }
427 }
428
429 /// Returns the logical unit number of a display.
430 #[inline]
431 pub fn unit_number(&self) -> u32 {
432 unsafe { CGDisplayUnitNumber(self.id) }
433 }
434
435 /// Returns the vendor number of the specified display's monitor.
436 #[inline]
437 pub fn vendor_number(&self) -> u32 {
438 unsafe { CGDisplayVendorNumber(self.id) }
439 }
440
441 /// Returns the model number of a display monitor.
442 #[inline]
443 pub fn model_number(&self) -> u32 {
444 unsafe { CGDisplayModelNumber(self.id) }
445 }
446
447 /// Returns the display height in pixel units.
448 #[inline]
449 pub fn pixels_high(&self) -> u64 {
450 unsafe { CGDisplayPixelsHigh(self.id) as u64 }
451 }
452
453 /// Returns the display width in pixel units.
454 #[inline]
455 pub fn pixels_wide(&self) -> u64 {
456 unsafe { CGDisplayPixelsWide(self.id) as u64 }
457 }
458
459 /// Provides a list of displays that are active (or drawable).
460 #[inline]
461 pub fn active_displays() -> Result<Vec<CGDirectDisplayID>, CGError> {
462 let count = CGDisplay::active_display_count()?;
463 let mut buf: Vec<CGDirectDisplayID> = vec![0; count as usize];
464 let result =
465 unsafe { CGGetActiveDisplayList(count as u32, buf.as_mut_ptr(), ptr::null_mut()) };
466 if result == 0 {
467 Ok(buf)
468 } else {
469 Err(result)
470 }
471 }
472
473 /// Provides count of displays that are active (or drawable).
474 #[inline]
475 pub fn active_display_count() -> Result<u32, CGError> {
476 let mut count: u32 = 0;
477 let result = unsafe { CGGetActiveDisplayList(0, ptr::null_mut(), &mut count) };
478 if result == 0 {
479 Ok(count as u32)
480 } else {
481 Err(result)
482 }
483 }
484
485 /// Hides the mouse cursor, and increments the hide cursor count.
486 #[inline]
487 pub fn hide_cursor(&self) -> Result<(), CGError> {
488 let result = unsafe { CGDisplayHideCursor(self.id) };
489 if result == 0 {
490 Ok(())
491 } else {
492 Err(result)
493 }
494 }
495
496 /// Decrements the hide cursor count, and shows the mouse cursor if the
497 /// count is 0.
498 #[inline]
499 pub fn show_cursor(&self) -> Result<(), CGError> {
500 let result = unsafe { CGDisplayShowCursor(self.id) };
501 if result == 0 {
502 Ok(())
503 } else {
504 Err(result)
505 }
506 }
507
508 /// Moves the mouse cursor to a specified point relative to the display
509 /// origin (the upper-left corner of the display).
510 #[inline]
511 pub fn move_cursor_to_point(&self, point: CGPoint) -> Result<(), CGError> {
512 let result = unsafe { CGDisplayMoveCursorToPoint(self.id, point) };
513 if result == 0 {
514 Ok(())
515 } else {
516 Err(result)
517 }
518 }
519
520 /// Moves the mouse cursor without generating events.
521 #[inline]
522 pub fn warp_mouse_cursor_position(point: CGPoint) -> Result<(), CGError> {
523 let result = unsafe { CGWarpMouseCursorPosition(point) };
524 if result == 0 {
525 Ok(())
526 } else {
527 Err(result)
528 }
529 }
530
531 /// Connects or disconnects the mouse and cursor while an application is
532 /// in the foreground.
533 #[inline]
534 pub fn associate_mouse_and_mouse_cursor_position(connected: bool) -> Result<(), CGError> {
535 let result = unsafe { CGAssociateMouseAndMouseCursorPosition(connected as boolean_t) };
536 if result == 0 {
537 Ok(())
538 } else {
539 Err(result)
540 }
541 }
542 }
543
544 impl CGDisplayMode {
545 /// Returns all display modes for the specified display id.
546 pub fn all_display_modes(
547 display_id: CGDirectDisplayID,
548 options: CFDictionaryRef,
549 ) -> Option<Vec<CGDisplayMode>> {
550 let array_opt: Option<CFArray> = unsafe {
551 let array_ref = CGDisplayCopyAllDisplayModes(display_id, options);
552 if !array_ref.is_null() {
553 Some(CFArray::wrap_under_create_rule(array_ref))
554 } else {
555 None
556 }
557 };
558 match array_opt {
559 Some(modes) => {
560 let vec: Vec<CGDisplayMode> = modes
561 .into_iter()
562 .map(|value0| {
563 let x = *value0.deref() as *mut ::sys::CGDisplayMode;
564 unsafe { CGDisplayMode::from_ptr(x) }
565 }).collect();
566 Some(vec)
567 }
568 None => None,
569 }
570 }
571
572 /// Returns the height of the specified display mode.
573 #[inline]
574 pub fn height(&self) -> u64 {
575 unsafe { CGDisplayModeGetHeight(self.as_ptr()) as u64 }
576 }
577
578 /// Returns the width of the specified display mode.
579 #[inline]
580 pub fn width(&self) -> u64 {
581 unsafe { CGDisplayModeGetWidth(self.as_ptr()) as u64 }
582 }
583
584 /// Returns the pixel height of the specified display mode.
585 #[inline]
586 pub fn pixel_height(&self) -> u64 {
587 unsafe { CGDisplayModeGetPixelHeight(self.as_ptr()) as u64 }
588 }
589
590 /// Returns the pixel width of the specified display mode.
591 #[inline]
592 pub fn pixel_width(&self) -> u64 {
593 unsafe { CGDisplayModeGetPixelWidth(self.as_ptr()) as u64 }
594 }
595
596 #[inline]
597 pub fn refresh_rate(&self) -> f64 {
598 unsafe { CGDisplayModeGetRefreshRate(self.as_ptr()) }
599 }
600
601 /// Returns the I/O Kit flags of the specified display mode.
602 #[inline]
603 pub fn io_flags(&self) -> u32 {
604 unsafe { CGDisplayModeGetIOFlags(self.as_ptr()) as u32 }
605 }
606
607 /// Returns the pixel encoding of the specified display mode.
608 #[inline]
609 pub fn pixel_encoding(&self) -> CFString {
610 unsafe { CFString::wrap_under_create_rule(CGDisplayModeCopyPixelEncoding(self.as_ptr())) }
611 }
612
613 /// Returns the number of bits per pixel of the specified display mode.
614 pub fn bit_depth(&self) -> usize {
615 let pixel_encoding = self.pixel_encoding().to_string();
616 // my numerical representation for kIO16BitFloatPixels and kIO32bitFloatPixels
617 // are made up and possibly non-sensical
618 if pixel_encoding.eq_ignore_ascii_case(kIO32BitFloatPixels) {
619 96
620 } else if pixel_encoding.eq_ignore_ascii_case(kIO64BitDirectPixels) {
621 64
622 } else if pixel_encoding.eq_ignore_ascii_case(kIO16BitFloatPixels) {
623 48
624 } else if pixel_encoding.eq_ignore_ascii_case(IO32BitDirectPixels) {
625 32
626 } else if pixel_encoding.eq_ignore_ascii_case(kIO30BitDirectPixels) {
627 30
628 } else if pixel_encoding.eq_ignore_ascii_case(IO16BitDirectPixels) {
629 16
630 } else if pixel_encoding.eq_ignore_ascii_case(IO8BitIndexedPixels) {
631 8
632 } else {
633 0
634 }
635 }
636
637 pub fn mode_id(&self) -> i32 {
638 unsafe { CGDisplayModeGetIODisplayModeID(self.as_ptr()) }
639 }
640 }
641
642 #[link(name = "CoreGraphics", kind = "framework")]
643 extern "C" {
644 pub static CGRectNull: CGRect;
645 pub static CGRectInfinite: CGRect;
646
647 pub static kCGDisplayShowDuplicateLowResolutionModes: CFStringRef;
648
649 pub fn CGDisplayModeRetain(mode: ::sys::CGDisplayModeRef);
650 pub fn CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef);
651
652 pub fn CGMainDisplayID() -> CGDirectDisplayID;
653 pub fn CGDisplayIsActive(display: CGDirectDisplayID) -> boolean_t;
654 pub fn CGDisplayIsAlwaysInMirrorSet(display: CGDirectDisplayID) -> boolean_t;
655 pub fn CGDisplayIsAsleep(display: CGDirectDisplayID) -> boolean_t;
656 pub fn CGDisplayIsBuiltin(display: CGDirectDisplayID) -> boolean_t;
657 pub fn CGDisplayIsInHWMirrorSet(display: CGDirectDisplayID) -> boolean_t;
658 pub fn CGDisplayIsInMirrorSet(display: CGDirectDisplayID) -> boolean_t;
659 pub fn CGDisplayIsMain(display: CGDirectDisplayID) -> boolean_t;
660 pub fn CGDisplayIsOnline(display: CGDirectDisplayID) -> boolean_t;
661 pub fn CGDisplayIsStereo(display: CGDirectDisplayID) -> boolean_t;
662 pub fn CGDisplayMirrorsDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID;
663 pub fn CGDisplayPrimaryDisplay(display: CGDirectDisplayID) -> CGDirectDisplayID;
664 pub fn CGDisplayRotation(display: CGDirectDisplayID) -> libc::c_double;
665 pub fn CGDisplayScreenSize(display: CGDirectDisplayID) -> CGSize;
666 pub fn CGDisplaySerialNumber(display: CGDirectDisplayID) -> u32;
667 pub fn CGDisplayUnitNumber(display: CGDirectDisplayID) -> u32;
668 pub fn CGDisplayUsesOpenGLAcceleration(display: CGDirectDisplayID) -> boolean_t;
669 pub fn CGDisplayVendorNumber(display: CGDirectDisplayID) -> u32;
670 pub fn CGGetActiveDisplayList(
671 max_displays: u32,
672 active_displays: *mut CGDirectDisplayID,
673 display_count: *mut u32,
674 ) -> CGError;
675 pub fn CGGetDisplaysWithRect(
676 rect: CGRect,
677 max_displays: u32,
678 displays: *mut CGDirectDisplayID,
679 matching_display_count: *mut u32,
680 ) -> CGError;
681 pub fn CGDisplayModelNumber(display: CGDirectDisplayID) -> u32;
682 pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t;
683 pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t;
684 pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect;
685 pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef;
686 pub fn CGDisplayCreateImageForRect(
687 display: CGDirectDisplayID,
688 rect: CGRect,
689 ) -> ::sys::CGImageRef;
690
691 // Capturing and Releasing Displays
692 pub fn CGDisplayCapture(display: CGDirectDisplayID) -> CGError;
693 pub fn CGDisplayRelease(display: CGDirectDisplayID) -> CGError;
694 pub fn CGShieldingWindowLevel() -> CGWindowLevel;
695
696 // Configuring Displays
697 pub fn CGBeginDisplayConfiguration(config: *mut CGDisplayConfigRef) -> CGError;
698 pub fn CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError;
699 pub fn CGCompleteDisplayConfiguration(
700 config: CGDisplayConfigRef,
701 option: CGConfigureOption,
702 ) -> CGError;
703 pub fn CGConfigureDisplayWithDisplayMode(
704 config: CGDisplayConfigRef,
705 display: CGDirectDisplayID,
706 mode: ::sys::CGDisplayModeRef,
707 options: CFDictionaryRef,
708 ) -> CGError;
709 pub fn CGConfigureDisplayMirrorOfDisplay(
710 config: CGDisplayConfigRef,
711 display: CGDirectDisplayID,
712 master: CGDirectDisplayID,
713 ) -> CGError;
714 pub fn CGConfigureDisplayOrigin(
715 config: CGDisplayConfigRef,
716 display: CGDirectDisplayID,
717 x: i32,
718 y: i32,
719 ) -> CGError;
720 pub fn CGRestorePermanentDisplayConfiguration();
721
722 pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef;
723 pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
724 pub fn CGDisplayModeGetWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
725 pub fn CGDisplayModeGetPixelHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
726 pub fn CGDisplayModeGetPixelWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
727 pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double;
728 pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> u32;
729 pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef;
730 pub fn CGDisplayModeGetIODisplayModeID(mode: ::sys::CGDisplayModeRef) -> i32;
731
732 pub fn CGDisplayCopyAllDisplayModes(
733 display: CGDirectDisplayID,
734 options: CFDictionaryRef,
735 ) -> CFArrayRef;
736 pub fn CGDisplaySetDisplayMode(
737 display: CGDirectDisplayID,
738 mode: ::sys::CGDisplayModeRef,
739 options: CFDictionaryRef,
740 ) -> CGError;
741
742 // mouse stuff
743 pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError;
744 pub fn CGDisplayShowCursor(display: CGDirectDisplayID) -> CGError;
745 pub fn CGDisplayMoveCursorToPoint(display: CGDirectDisplayID, point: CGPoint) -> CGError;
746 pub fn CGWarpMouseCursorPosition(point: CGPoint) -> CGError;
747 pub fn CGAssociateMouseAndMouseCursorPosition(connected: boolean_t) -> CGError;
748
749 // Display Fade Effects
750 pub fn CGConfigureDisplayFadeEffect(
751 config: CGDisplayConfigRef,
752 fadeOutSeconds: CGDisplayFadeInterval,
753 fadeInSeconds: CGDisplayFadeInterval,
754 fadeRed: f32,
755 fadeGreen: f32,
756 fadeBlue: f32,
757 ) -> CGError;
758 pub fn CGAcquireDisplayFadeReservation(
759 seconds: CGDisplayReservationInterval,
760 token: *mut CGDisplayFadeReservationToken,
761 ) -> CGError;
762 pub fn CGDisplayFade(
763 token: CGDisplayFadeReservationToken,
764 duration: CGDisplayFadeInterval,
765 startBlend: CGDisplayBlendFraction,
766 endBlend: CGDisplayBlendFraction,
767 redBlend: f32,
768 greenBlend: f32,
769 blueBlend: f32,
770 synchronous: boolean_t,
771 ) -> CGError;
772 // CGDisplayFadeOperationInProgress
773 pub fn CGReleaseDisplayFadeReservation(token: CGDisplayFadeReservationToken) -> CGError;
774
775 // Window Services Reference
776 pub fn CGWindowListCopyWindowInfo(
777 option: CGWindowListOption,
778 relativeToWindow: CGWindowID,
779 ) -> CFArrayRef;
780 pub fn CGWindowListCreateImage(
781 screenBounds: CGRect,
782 listOptions: CGWindowListOption,
783 windowId: CGWindowID,
784 imageOptions: CGWindowImageOption,
785 ) -> ::sys::CGImageRef;
786 pub fn CGWindowListCreateImageFromArray(
787 screenBounds: CGRect,
788 windowArray: CFArrayRef,
789 imageOptions: CGWindowImageOption,
790 ) -> ::sys::CGImageRef;
791 }