From 75e985d08eb784e413a3d184f397bc136e10a364 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sun, 1 May 2016 10:16:39 +0200 Subject: [PATCH] Added get_size() on Unix --- src/native/x11/X11MiniFB.c | 11 ++++++++++- src/os/unix/mod.rs | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/native/x11/X11MiniFB.c b/src/native/x11/X11MiniFB.c index 538c65c..0957055 100644 --- a/src/native/x11/X11MiniFB.c +++ b/src/native/x11/X11MiniFB.c @@ -154,7 +154,9 @@ void* mfb_open(const char* title, int width, int height, unsigned int flags, int //XSelectInput(s_display, s_window, KeyPressMask | KeyReleaseMask); XStoreName(s_display, window, title); - XSelectInput(s_display, window, ButtonPressMask | KeyPressMask | KeyReleaseMask | ButtonReleaseMask); + XSelectInput(s_display, window, + StructureNotifyMask | + ButtonPressMask | KeyPressMask | KeyReleaseMask | ButtonReleaseMask); if (!(flags & WINDOW_RESIZE)) { sizeHints.flags = PPosition | PMinSize | PMaxSize; @@ -291,6 +293,13 @@ static int process_event(XEvent* event) { break; } + + case ConfigureNotify: + { + info->width = event->xconfigure.width; + info->height = event->xconfigure.height; + break; + } } return 1; diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index f39155b..3adb5a3 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -235,7 +235,7 @@ impl Window { #[inline] pub fn get_size(&self) -> (usize, usize) { - (0, 0) + (self.shared_data.width as usize, self.shared_data.height as usize) } pub fn get_mouse_pos(&self, mode: MouseMode) -> Option<(f32, f32)> {