diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-07-31 17:01:58 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-07-31 17:01:58 +0200 |
commit | 0c76ff877106dd71972b8e0c47a0a8ba2e5e7099 (patch) | |
tree | 1c3eb78b7048360144c43abf54836abb96ee32bb /src/x11/mod.rs | |
parent | 37c5b5446b4dcb6163a9c3119f9c8ca7cbf986c8 (diff) | |
download | glutin-0c76ff877106dd71972b8e0c47a0a8ba2e5e7099.tar.gz glutin-0c76ff877106dd71972b8e0c47a0a8ba2e5e7099.zip |
Add get_position and get_inner_size for X11
Diffstat (limited to 'src/x11/mod.rs')
-rw-r--r-- | src/x11/mod.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/x11/mod.rs b/src/x11/mod.rs index 61488a1..4bd186f 100644 --- a/src/x11/mod.rs +++ b/src/x11/mod.rs @@ -136,8 +136,31 @@ impl Window { } } + fn get_geometry(&self) -> Option<(int, int, uint, uint)> { + unsafe { + use std::mem; + + let mut root: ffi::Window = mem::uninitialized(); + let mut x: libc::c_int = mem::uninitialized(); + let mut y: libc::c_int = mem::uninitialized(); + let mut width: libc::c_uint = mem::uninitialized(); + let mut height: libc::c_uint = mem::uninitialized(); + let mut border: libc::c_uint = mem::uninitialized(); + let mut depth: libc::c_uint = mem::uninitialized(); + + if ffi::XGetGeometry(self.display, self.window, + &mut root, &mut x, &mut y, &mut width, &mut height, + &mut border, &mut depth) == 0 + { + return None; + } + + Some((x as int, y as int, width as uint, height as uint)) + } + } + pub fn get_position(&self) -> Option<(int, int)> { - unimplemented!() + self.get_geometry().map(|(x, y, _, _)| (x, y)) } pub fn set_position(&self, x: uint, y: uint) { @@ -145,7 +168,7 @@ impl Window { } pub fn get_inner_size(&self) -> Option<(uint, uint)> { - unimplemented!() + self.get_geometry().map(|(_, _, w, h)| (w, h)) } pub fn get_outer_size(&self) -> Option<(uint, uint)> { |