mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 14:45:28 +00:00
Fixed few bugs related to getting mouse coordinates
This commit is contained in:
parent
3d58a0b50a
commit
e5ab1ae791
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue