aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Bakker <rubenbak@gmail.com>2015-12-29 21:52:18 +0200
committerRuben Bakker <rubenbak@gmail.com>2015-12-29 21:52:18 +0200
commitd892ba168b178d5adac2db777b3dfc912543d40b (patch)
tree8d97d892a885bf07d0baf3563e3c79ae93fd99ef
parent2fb150b345c0c27f289b140e763df7764561946e (diff)
downloadglutin-d892ba168b178d5adac2db777b3dfc912543d40b.tar.gz
glutin-d892ba168b178d5adac2db777b3dfc912543d40b.zip
Reduce cursor warp delay with CGAssociateMouseAndMouseCursorPosition
-rw-r--r--src/api/cocoa/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index 2a5f3ec..a720a51 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -766,14 +766,16 @@ impl Window {
#[inline]
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
+ let (window_x, window_y) = self.get_position().unwrap_or((0, 0));
+ let (cursor_x, cursor_y) = (window_x + x, window_y + y);
+
unsafe {
- let (window_x, window_y) = self.get_position().unwrap_or((0, 0));
- let (cursor_x, cursor_y) = (window_x + x, window_y + y);
-
// TODO: Check for errors.
let _ = CGWarpMouseCursorPosition(CGPoint { x: cursor_x as CGFloat, y: cursor_y as CGFloat });
- Ok(())
+ let _ = CGAssociateMouseAndMouseCursorPosition(true);
}
+
+ Ok(())
}
}