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: Only fire location changed when size changes and form is loaded. #2623

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
32 changes: 18 additions & 14 deletions src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,14 @@ public override void AttachEvent(string id)
handler.Callback.OnSizeChanged(handler.Widget, EventArgs.Empty);
oldSize = newSize;
}
var old = handler.oldLocation;
handler.oldLocation = null;
var newLocation = handler.Location;
if (old != newLocation)
if (handler.Widget.Loaded)
{
handler.oldLocation = newLocation;
handler.Callback.OnLocationChanged(handler.Widget, EventArgs.Empty);
var newLocation = handler.GetLocation();
if (handler.oldLocation != newLocation)
{
handler.oldLocation = newLocation;
handler.Callback.OnLocationChanged(handler.Widget, EventArgs.Empty);
}
}
});
}
Expand All @@ -419,10 +420,8 @@ public override void AttachEvent(string id)
var handler = e.Handler as MacWindow<TControl, TWidget, TCallback>;
if (handler != null)
{
var old = handler.oldLocation;
handler.oldLocation = null;
var newLocation = handler.Location;
if (old != newLocation)
var newLocation = handler.GetLocation();
if (handler.oldLocation != newLocation)
{
handler.oldLocation = newLocation;
handler.Callback.OnLocationChanged(handler.Widget, EventArgs.Empty);
Expand Down Expand Up @@ -982,10 +981,7 @@ public virtual Point Location
return oldLocation.Value;
if (!Widget.Loaded && InitialLocation != null)
return InitialLocation.Value;
// translate location relative to the top left corner of main screen
var mainFrame = NSScreen.Screens[0].Frame;
var frame = Control.Frame;
return new Point((int)frame.X, (int)(mainFrame.Height - frame.Y - frame.Height));
return GetLocation();
}
set
{
Expand All @@ -999,6 +995,14 @@ public virtual Point Location
}
}

private Point GetLocation()
{
// translate location relative to the top left corner of main screen
var mainFrame = NSScreen.Screens[0].Frame;
var frame = Control.Frame;
return new Point((int)frame.X, (int)(mainFrame.Height - frame.Y - frame.Height));
}

void SetLocation(Point value)
{
// location is relative to the main screen, translate to bottom left, inversed
Expand Down
Loading