mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-29 18:06:52 +00:00
[Mac] Mouse coordinates are reported in pixels
This commit is contained in:
parent
e0848f9d6d
commit
3475582c30
|
@ -451,18 +451,24 @@ namespace OpenTK.Platform.MacOS
|
||||||
case NSEventType.MouseMoved:
|
case NSEventType.MouseMoved:
|
||||||
{
|
{
|
||||||
var pf = Cocoa.SendPoint(e, selLocationInWindowOwner);
|
var pf = Cocoa.SendPoint(e, selLocationInWindowOwner);
|
||||||
var p = new Point((int)pf.X, (int)pf.Y);
|
|
||||||
|
|
||||||
var s = ClientSize;
|
// Convert from points to pixel coordinates
|
||||||
|
var rf = Cocoa.SendRect(windowInfo.Handle, selConvertRectToBacking,
|
||||||
|
new RectangleF(pf.X, pf.Y, 0, 0));
|
||||||
|
|
||||||
|
// See CocoaDrawingGuide under "Converting from Window to View Coordinates"
|
||||||
|
var p = new Point(
|
||||||
|
MathHelper.Clamp((int)Math.Round(rf.X), 0, Width),
|
||||||
|
MathHelper.Clamp((int)Math.Round(Height - rf.Y), 0, Height));
|
||||||
|
|
||||||
if (p.X < 0)
|
if (p.X < 0)
|
||||||
p.X = 0;
|
p.X = 0;
|
||||||
if (p.Y < 0)
|
if (p.Y < 0)
|
||||||
p.Y = 0;
|
p.Y = 0;
|
||||||
if (p.X > s.Width)
|
if (p.X > Width)
|
||||||
p.X = s.Width;
|
p.X = Width;
|
||||||
if (p.Y > s.Height)
|
if (p.Y > Height)
|
||||||
p.Y = s.Height;
|
p.Y = Height;
|
||||||
p.Y = s.Height - p.Y;
|
|
||||||
|
|
||||||
InputDriver.Mouse[0].Position = p;
|
InputDriver.Mouse[0].Position = p;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue