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: Non-activating forms with an owner should not show overtop existing windows #2377

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/Eto.Mac/Forms/FormHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ public virtual void Show()
Control.MakeKeyWindow();
else
Control.MakeKeyAndOrderFront(ApplicationHandler.Instance.AppDelegate);

// setting the owner shows the window, so we have to do this after making the window key
EnsureOwner();
}
else
else if (!EnsureOwner())
{
// only order front when there is no owner as it'll bring the owner above any existing non-child windows
Control.OrderFront(ApplicationHandler.Instance.AppDelegate);
}

// setting the owner shows the window, so we have to do this here.
EnsureOwner();

if (!visible)
{
Expand Down
9 changes: 7 additions & 2 deletions src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,10 +1247,13 @@ public bool SetAsChildWindow
set => Widget.Properties.Set(MacWindow.SetAsChildWindow_Key, value, DefaultSetAsChildWindow);
}

protected void EnsureOwner() => SetOwner(Widget.Owner);
protected bool EnsureOwner() => InternalSetOwner(Widget.Owner);

public virtual void SetOwner(Window owner)
public virtual void SetOwner(Window owner) => InternalSetOwner(owner);

bool InternalSetOwner(Window owner)
{
bool result = false;
if (SetAsChildWindow && Widget.Loaded)
{
if (owner != null)
Expand All @@ -1260,6 +1263,7 @@ public virtual void SetOwner(Window owner)
{
macWindow.Control.AddChildWindow(Control, NSWindowOrderingMode.Above);
OnSetAsChildWindow();
result = true;
}
Widget.GotFocus += HandleGotFocusAsChild;
}
Expand All @@ -1271,6 +1275,7 @@ public virtual void SetOwner(Window owner)
parentWindow.RemoveChildWindow(Control);
}
}
return result;
}

void HandleGotFocusAsChild(object sender, EventArgs e)
Expand Down