Fixed few bugs related to getting mouse coordinates

This commit is contained in:
TD25 2016-02-22 02:27:18 +02:00
parent 3d58a0b50a
commit e5ab1ae791
4 changed files with 11 additions and 32 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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)

View file

@ -577,26 +577,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