From c61c33a833ebbf874885d3c48491f8307bffe68e Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 10 Mar 2015 10:29:07 +0100 Subject: Add set_cursor_position function --- src/win32/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/win32') diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 8cb6d39..8ba5ed5 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -255,6 +255,25 @@ impl Window { pub fn hidpi_factor(&self) -> f32 { 1.0 } + + pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()> { + let mut point = winapi::POINT { + x: x, + y: y, + }; + + unsafe { + if user32::ClientToScreen(self.window.0, &mut point) == 0 { + return Err(()); + } + + if user32::SetCursorPos(point.x, point.y) == 0 { + return Err(()); + } + } + + Ok(()) + } } pub struct PollEventsIterator<'a> { -- cgit v1.2.3