From aaa1c76841f2b895785e0c34ecd8d0c99e16ab23 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 26 Mar 2015 17:33:49 +0100 Subject: Fix compilation on x11 --- src/x11/window/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/x11') diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 4c2fae8..7c93ad3 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -283,7 +283,7 @@ pub struct Window { current_size: Cell<(libc::c_int, libc::c_int)>, /// Events that have been retreived with XLib but not dispatched with iterators yet pending_events: Mutex>, - cursor_state: CursorState, + cursor_state: Mutex, } impl Window { @@ -603,7 +603,7 @@ impl Window { wm_delete_window: wm_delete_window, current_size: Cell::new((0, 0)), pending_events: Mutex::new(VecDeque::new()), - cursor_state: CursorState::Normal, + cursor_state: Mutex::new(CursorState::Normal), }; // returning @@ -786,17 +786,20 @@ impl Window { } pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> { - match (state, self.cursor_state) { + let mut cursor_state = self.cursor_state.lock().unwrap(); + + match (state, *cursor_state) { (CursorState::Normal, CursorState::Grab) => { unsafe { ffi::XUngrabPointer(self.x.display, ffi::CurrentTime); - self.cursor_state = CursorState::Normal; + *cursor_state = CursorState::Normal; + Ok(()) } }, (CursorState::Grab, CursorState::Normal) => { unsafe { - self.cursor_state = CursorState::Grab; + *cursor_state = CursorState::Grab; match ffi::XGrabPointer( self.x.display, self.x.window, false, -- cgit v1.2.3