mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-30 21:30:03 -04:00
Merge pull request #476 from aepsil0n/x11-cursor-grab-fix
Fix set_cursor_state on X11
This commit is contained in:
@@ -711,20 +711,22 @@ impl Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
|
use CursorState::{ Grab, Normal };
|
||||||
|
|
||||||
let mut cursor_state = self.cursor_state.lock().unwrap();
|
let mut cursor_state = self.cursor_state.lock().unwrap();
|
||||||
|
|
||||||
match (state, *cursor_state) {
|
match (state, *cursor_state) {
|
||||||
(CursorState::Normal, CursorState::Grab) => {
|
(Normal, Grab) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
(self.x.display.xlib.XUngrabPointer)(self.x.display.display, ffi::CurrentTime);
|
(self.x.display.xlib.XUngrabPointer)(self.x.display.display, ffi::CurrentTime);
|
||||||
*cursor_state = CursorState::Normal;
|
*cursor_state = Normal;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
(CursorState::Grab, CursorState::Normal) => {
|
(Grab, Normal) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
*cursor_state = CursorState::Grab;
|
*cursor_state = Grab;
|
||||||
|
|
||||||
match (self.x.display.xlib.XGrabPointer)(
|
match (self.x.display.xlib.XGrabPointer)(
|
||||||
self.x.display.display, self.x.window, ffi::False,
|
self.x.display.display, self.x.window, ffi::False,
|
||||||
@@ -745,6 +747,9 @@ impl Window {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Nothing needs to change
|
||||||
|
(Grab, Grab) | (Normal, Normal) => Ok(()),
|
||||||
|
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user