Skip to content

Commit

Permalink
Hide cursor when grabbed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nopey committed May 16, 2019
1 parent 97741d4 commit 6794cc9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,18 @@ impl AdvancedWindow for WinitWindow {
return;
}

let window = self.get_window();
if value {
self.get_window().grab_cursor(true).unwrap();
window.grab_cursor(true).unwrap();
window.hide_cursor(true);
self.cursor_accumulator = LogicalPosition::new(0.0, 0.0);
let mut center = self.get_window().get_inner_size().unwrap_or(LogicalSize::new(2., 2.));
center.width /= 2.;
center.height /= 2.;
self.last_cursor = LogicalPosition::new(center.width, center.height);
} else {
self.get_window().grab_cursor(false).unwrap();
window.grab_cursor(false).unwrap();
window.hide_cursor(false);
}
self.capture_cursor = value;
}
Expand Down

0 comments on commit 6794cc9

Please sign in to comment.