mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
Reduce cursor warp delay with CGAssociateMouseAndMouseCursorPosition
This commit is contained in:
parent
2fb150b345
commit
d892ba168b
1 changed files with 6 additions and 4 deletions
|
@ -766,14 +766,16 @@ impl Window {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> {
|
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 {
|
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.
|
// TODO: Check for errors.
|
||||||
let _ = CGWarpMouseCursorPosition(CGPoint { x: cursor_x as CGFloat, y: cursor_y as CGFloat });
|
let _ = CGWarpMouseCursorPosition(CGPoint { x: cursor_x as CGFloat, y: cursor_y as CGFloat });
|
||||||
Ok(())
|
let _ = CGAssociateMouseAndMouseCursorPosition(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue