From 8f74e167fcb72a2e630136e75e12d43ab843eb94 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Thu, 29 Oct 2015 09:35:49 -0700 Subject: [PATCH 1/2] Fix WindowAttribs to not include a *c_void member for serialization --- src/api/x11/window.rs | 10 ++++------ src/lib.rs | 26 ++++++++++++++++++++------ src/window.rs | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs index 2da53d6ae7..0f09561c1c 100644 --- a/src/api/x11/window.rs +++ b/src/api/x11/window.rs @@ -401,13 +401,11 @@ impl Window { }, }; - // getting the parent window - let parent = if window_attrs.parent.is_null() { - unsafe { (display.xlib.XDefaultRootWindow)(display.display) } - } else { - window_attrs.parent as ffi::Window + // getting the parent window; root if None + let parent = match window_attrs.parent { + Some(ref w) => w.window as ffi::Window, + None => unsafe { (display.xlib.XDefaultRootWindow)(display.display) } }; - // getting the root window // creating the color map let cmap = unsafe { diff --git a/src/lib.rs b/src/lib.rs index 4a774820cc..406d1e0cfb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -519,6 +519,23 @@ impl Default for PixelFormatRequirements { } } +/// A wrapper for a native window pointer. +#[derive(Debug, Clone)] +pub struct WindowID { + pub window: *mut libc::c_void, +} + +impl WindowID { + pub fn new(window: *mut libc::c_void) -> WindowID { + WindowID { + window: window + } + } +} + +unsafe impl Send for WindowID {} +unsafe impl Sync for WindowID {} + /// Attributes to use when creating a window. #[derive(Clone)] pub struct WindowAttributes { @@ -560,8 +577,8 @@ pub struct WindowAttributes { /// Parent Window. /// - /// The default is `std::ptr::null_mut()` - pub parent: WindowID, + /// The default is `None`. + pub parent: Option, } impl Default for WindowAttributes { @@ -575,7 +592,7 @@ impl Default for WindowAttributes { transparent: false, decorations: true, multitouch: false, - parent: std::ptr::null_mut(), + parent: None, } } } @@ -662,6 +679,3 @@ mod native_monitor { Unavailable } } - -/// Identifier for a display system window. -pub type WindowID = *mut libc::c_void; diff --git a/src/window.rs b/src/window.rs index aa7804a5f4..4bb553c5aa 100644 --- a/src/window.rs +++ b/src/window.rs @@ -197,7 +197,7 @@ impl<'a> WindowBuilder<'a> { } /// Sets the parent window - pub fn with_parent(mut self, parent: WindowID) -> WindowBuilder<'a> { + pub fn with_parent(mut self, parent: Option) -> WindowBuilder<'a> { self.window.parent = parent; self } From 4f5be901db3ed7ea964153eca92d120aa486eedf Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Tue, 22 Sep 2015 09:41:29 -0400 Subject: [PATCH 2/2] Implement some missing win32 bits --- src/api/win32/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/win32/mod.rs b/src/api/win32/mod.rs index 4fb3635cd2..2948b33cf4 100644 --- a/src/api/win32/mod.rs +++ b/src/api/win32/mod.rs @@ -254,7 +254,8 @@ impl Window { #[inline] pub fn set_cursor(&self, _cursor: MouseCursor) { - unimplemented!() + // XXX FIXME -- ignore this for now, we need to implement this + //unimplemented!() } pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {