From f3bd5ddb29a8e2e7299a40f09578ccf017389a32 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sat, 9 Jan 2016 20:54:46 +0100 Subject: [PATCH] Added X11 set_position --- src/native/x11/X11MiniFB.c | 10 ++++++++++ src/os/unix/mod.rs | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/native/x11/X11MiniFB.c b/src/native/x11/X11MiniFB.c index 333b7d7..1100bdc 100644 --- a/src/native/x11/X11MiniFB.c +++ b/src/native/x11/X11MiniFB.c @@ -324,6 +324,16 @@ void mfb_update(void* window_info, void* buffer) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void mfb_set_position(void* window, int x, int y) +{ + WindowInfo* info = (WindowInfo*)window_info; + + XMoveWindow(s_display, info->window, x, y); + XFlush(s_display); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void mfb_close(void* window_info) { WindowInfo* info = (WindowInfo*)window_info; diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index 089e06e..06c7baa 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -20,6 +20,7 @@ extern { fn mfb_open(name: *const c_char, width: u32, height: u32, scale: i32) -> *mut c_void; fn mfb_close(window: *mut c_void); fn mfb_update(window: *mut c_void, buffer: *const c_uchar); + fn mfb_set_position(window: *mut c_void, x: i32, y: i32); fn mfb_set_key_callback(window: *mut c_void, target: *mut c_void, cb: unsafe extern fn(*mut c_void, i32, i32)); fn mfb_should_close(window: *mut c_void) -> i32; fn mfb_get_screen_size() -> u32; @@ -177,6 +178,7 @@ impl Window { #[inline] pub fn set_position(&mut self, _: isize, _: isize) { + unsafe { mfb_set_position(self.window_handle, x as i32, y as i32) } } #[inline]