Skip to content

Commit f573f25

Browse files
authoredJan 9, 2023
Merge pull request #2377 from cwensley/curtis/mac-order-front-with-owner
Mac: Non-activating forms with an owner should not show overtop existing windows
2 parents 6eb7332 + c12db10 commit f573f25

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed
 

‎src/Eto.Mac/Forms/FormHandler.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ public virtual void Show()
7070
Control.MakeKeyWindow();
7171
else
7272
Control.MakeKeyAndOrderFront(ApplicationHandler.Instance.AppDelegate);
73+
74+
// setting the owner shows the window, so we have to do this after making the window key
75+
EnsureOwner();
7376
}
74-
else
77+
else if (!EnsureOwner())
7578
{
79+
// only order front when there is no owner as it'll bring the owner above any existing non-child windows
7680
Control.OrderFront(ApplicationHandler.Instance.AppDelegate);
7781
}
78-
79-
// setting the owner shows the window, so we have to do this here.
80-
EnsureOwner();
8182

8283
if (!visible)
8384
{

‎src/Eto.Mac/Forms/MacWindow.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,13 @@ public bool SetAsChildWindow
12471247
set => Widget.Properties.Set(MacWindow.SetAsChildWindow_Key, value, DefaultSetAsChildWindow);
12481248
}
12491249

1250-
protected void EnsureOwner() => SetOwner(Widget.Owner);
1250+
protected bool EnsureOwner() => InternalSetOwner(Widget.Owner);
12511251

1252-
public virtual void SetOwner(Window owner)
1252+
public virtual void SetOwner(Window owner) => InternalSetOwner(owner);
1253+
1254+
bool InternalSetOwner(Window owner)
12531255
{
1256+
bool result = false;
12541257
if (SetAsChildWindow && Widget.Loaded)
12551258
{
12561259
if (owner != null)
@@ -1260,6 +1263,7 @@ public virtual void SetOwner(Window owner)
12601263
{
12611264
macWindow.Control.AddChildWindow(Control, NSWindowOrderingMode.Above);
12621265
OnSetAsChildWindow();
1266+
result = true;
12631267
}
12641268
Widget.GotFocus += HandleGotFocusAsChild;
12651269
}
@@ -1271,6 +1275,7 @@ public virtual void SetOwner(Window owner)
12711275
parentWindow.RemoveChildWindow(Control);
12721276
}
12731277
}
1278+
return result;
12741279
}
12751280

12761281
void HandleGotFocusAsChild(object sender, EventArgs e)

0 commit comments

Comments
 (0)
Please sign in to comment.