diff --git a/Source/OpenTK/Platform/Linux/LinuxNativeWindow.cs b/Source/OpenTK/Platform/Linux/LinuxNativeWindow.cs index 81c20a53..200b8e09 100644 --- a/Source/OpenTK/Platform/Linux/LinuxNativeWindow.cs +++ b/Source/OpenTK/Platform/Linux/LinuxNativeWindow.cs @@ -351,27 +351,14 @@ namespace OpenTK.Platform.Linux public override Point PointToClient(Point point) { - var origin = Point.Empty; - var display = DisplayDevice.Default; - if (display != null) - { - origin = display.Bounds.Location; - } var client = Location; - return new Point(point.X + client.X - origin.X, point.Y + client.Y - origin.Y); + return new Point(point.X - client.X, point.Y - client.Y); } public override Point PointToScreen(Point point) { - var origin = Point.Empty; - var display = DisplayDevice.Default; - if (display != null) - { - origin = display.Bounds.Location; - } var client = Location; - return new Point(point.X + origin.X - client.X, point.Y + origin.Y - client.Y); - + return new Point(point.X + client.X, point.Y + client.Y); } protected override void Dispose(bool disposing) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2.cs b/Source/OpenTK/Platform/SDL2/Sdl2.cs index 7f0c3058..35783957 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2.cs @@ -248,6 +248,10 @@ namespace OpenTK.Platform.SDL2 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetMouseState", ExactSpelling = true)] public static extern ButtonFlags GetMouseState(out int hx, out int hy); + [SuppressUnmanagedCodeSecurity] + [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetGlobalMouseState", ExactSpelling = true)] + public static extern ButtonFlags GetGlobalMouseState(out int hx, out int hy); + [SuppressUnmanagedCodeSecurity] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_GetNumDisplayModes", ExactSpelling = true)] public static extern int GetNumDisplayModes(int displayIndex); diff --git a/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs b/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs index cbccd7eb..af8039b1 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs @@ -124,7 +124,7 @@ namespace OpenTK.Platform.SDL2 public MouseState GetCursorState() { int x, y; - var buttons = SDL.GetMouseState(out x, out y); + var buttons = SDL.GetGlobalMouseState(out x, out y); var c = new MouseState(); c.SetIsConnected(true); @@ -137,7 +137,7 @@ namespace OpenTK.Platform.SDL2 c[MouseButton.Button1] = (buttons & ButtonFlags.X1) != 0; c[MouseButton.Button2] = (buttons & ButtonFlags.X2) != 0; - return state; + return c; } public void SetPosition(double x, double y) @@ -145,7 +145,7 @@ namespace OpenTK.Platform.SDL2 SDL.WarpMouseInWindow(IntPtr.Zero, (int)x, (int)y); } - #endregion + #endregion } } diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index 653a9835..6fdcbf91 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -579,26 +579,14 @@ namespace OpenTK.Platform.SDL2 public override Point PointToClient(Point point) { - var origin = Point.Empty; - var display = DisplayDevice.Default; - if (display != null) - { - origin = display.Bounds.Location; - } var client = Location; - return new Point(point.X + client.X - origin.X, point.Y + client.Y - origin.Y); + return new Point(point.X - client.X, point.Y - client.Y); } public override Point PointToScreen(Point point) { - var origin = Point.Empty; - var display = DisplayDevice.Default; - if (display != null) - { - origin = display.Bounds.Location; - } var client = Location; - return new Point(point.X + origin.X - client.X, point.Y + origin.Y - client.Y); + return new Point(point.X + client.X, point.Y + client.Y); } public override Icon Icon