Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: Use current event window when calling PointToScreen if needed #2572

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,15 +1213,15 @@ public virtual PointF PointFromScreen(PointF point)
{
var pt = point.ToNS();
var view = ContainerControl;
var window = view.Window;

// macOS has flipped co-ordinates starting at the bottom left of the main screen,
// so we flip to make 0,0 top left
var mainFrame = NSScreen.Screens[0].Frame;
pt.Y = mainFrame.Height - pt.Y;
var window = view.Window ?? NSApplication.SharedApplication.CurrentEvent?.Window;
if (window != null)
{
// macOS has flipped co-ordinates starting at the bottom left of the main screen,
// so we flip to make 0,0 top left
var mainFrame = NSScreen.Screens[0].Frame;
pt.Y = mainFrame.Height - pt.Y;
pt = window.ConvertScreenToBase(pt);
}

pt = view.ConvertPointFromView(pt, null);
if (!view.IsFlipped)
pt.Y = view.Frame.Height - pt.Y;
Expand All @@ -1237,15 +1237,12 @@ public virtual PointF PointToScreen(PointF point)
if (!view.IsFlipped)
pt.Y = view.Frame.Height - pt.Y;
pt = view.ConvertPointToView(pt, null);
var window = view.Window;
var window = view.Window ?? NSApplication.SharedApplication.CurrentEvent?.Window;
if (window != null)
{
pt = window.ConvertBaseToScreen(pt);
// macOS has flipped co-ordinates starting at the bottom left of the main screen,
// so we flip to make 0,0 top left
var mainFrame = NSScreen.Screens[0].Frame;
pt.Y = mainFrame.Height - pt.Y;
}

var mainFrame = NSScreen.Screens[0].Frame;
pt.Y = mainFrame.Height - pt.Y;
return pt.ToEto();
}

Expand Down
Loading