From 2fca9b2b13b5a4e7d35d45aeca4552cad6c359e0 Mon Sep 17 00:00:00 2001 From: Vlad Kalyuzhny Date: Tue, 25 Jul 2017 00:36:33 +0300 Subject: [PATCH] Fix cursor incorreclty moved out of window --- src/OpenTK/Platform/SDL2/Sdl2.cs | 4 ++++ src/OpenTK/Platform/SDL2/Sdl2Mouse.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenTK/Platform/SDL2/Sdl2.cs b/src/OpenTK/Platform/SDL2/Sdl2.cs index 5a77a8ff..130a3fd0 100644 --- a/src/OpenTK/Platform/SDL2/Sdl2.cs +++ b/src/OpenTK/Platform/SDL2/Sdl2.cs @@ -490,6 +490,10 @@ namespace OpenTK.Platform.SDL2 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WarpMouseInWindow", ExactSpelling = true)] public static extern void WarpMouseInWindow(IntPtr window, int x, int y); + [SuppressUnmanagedCodeSecurity] + [DllImport (lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_WarpMouseGlobal", ExactSpelling = true)] + public static extern void WarpMouseGlobal(int x, int y); + /// /// Retrieves driver-dependent window information. /// diff --git a/src/OpenTK/Platform/SDL2/Sdl2Mouse.cs b/src/OpenTK/Platform/SDL2/Sdl2Mouse.cs index 894bb09a..23de55b2 100644 --- a/src/OpenTK/Platform/SDL2/Sdl2Mouse.cs +++ b/src/OpenTK/Platform/SDL2/Sdl2Mouse.cs @@ -146,7 +146,7 @@ namespace OpenTK.Platform.SDL2 public void SetPosition(double x, double y) { - SDL.WarpMouseInWindow(IntPtr.Zero, (int)x, (int)y); + SDL.WarpMouseGlobal((int)x, (int)y); } } }