[SDL] Avoid CursorVisible = true cursor jump

This commit is contained in:
thefiddler 2014-05-06 09:36:30 +02:00
parent a270b9328e
commit e3fd9e1374

View file

@ -397,6 +397,16 @@ namespace OpenTK.Platform.SDL2
SDL.ShowCursor(!grab);
SDL.SetWindowGrab(window.Handle, grab);
SDL.SetRelativeMouseMode(grab);
if (!grab)
{
// Move the cursor to the current position
// in order to avoid a sudden jump when it
// becomes visible again
float scale = Width / (float)Size.Width;
SDL.WarpMouseInWindow(window.Handle,
(int)Math.Round(MouseState.X / scale),
(int)Math.Round(MouseState.Y / scale));
}
}
// Hack to force WindowState events to be pumped