Skip to content

Commit

Permalink
Auto merge of #343 - zubivan:master, r=jdm
Browse files Browse the repository at this point in the history
Add CGConfigureDisplayOrigin

Adds a wrapper for [CGConfigureDisplayOrigin](https://developer.apple.com/documentation/coregraphics/1454090-cgconfiguredisplayorigin) which has the following signature:

``` c
func CGConfigureDisplayOrigin(_ config: CGDisplayConfigRef?,
                            _ display: CGDirectDisplayID,
                            _ x: Int32,
                            _ y: Int32) -> CGError
```

Please let me know if there is anything I can improve here.

I'm currently working on the small utility heavily relying on CoreGraphics API, so expect more of those to come as I go. :)
  • Loading branch information
bors-servo committed Oct 23, 2019
2 parents 70aca43 + 580e171 commit 12c15a5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core-graphics/src/display.rs
Expand Up @@ -200,6 +200,22 @@ impl CGDisplay {
}
}

// Configures the origin of a display in the global display coordinate space.
pub fn configure_display_origin(
&self,
config_ref: &CGDisplayConfigRef,
x: i32,
y: i32,
) -> Result<(), CGError> {
let result = unsafe { CGConfigureDisplayOrigin(*config_ref, self.id, x, y) };

if result == 0 {
Ok(())
} else {
Err(result)
}
}

/// Returns an image containing the contents of the specified display.
#[inline]
pub fn image(&self) -> Option<CGImage> {
Expand Down Expand Up @@ -630,6 +646,12 @@ extern "C" {
mode: ::sys::CGDisplayModeRef,
options: CFDictionaryRef,
) -> CGError;
pub fn CGConfigureDisplayOrigin(
config: CGDisplayConfigRef,
display: CGDirectDisplayID,
x: i32,
y: i32,
) -> CGError;

pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef;
pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
Expand Down

0 comments on commit 12c15a5

Please sign in to comment.