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

Wpf: Clear owner before setting Visible to false #2690

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: 18 additions & 7 deletions src/Eto.Wpf/Forms/WpfWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,18 +1079,21 @@ public void SetOwner(Window owner)
{
if (owner == null)
{
// Clear out WPF owner
Control.Owner = null;
return;

// If the owner was set to an HWND clear that out too.
var interop = windowInterop ?? new sw.Interop.WindowInteropHelper(Control);
interop.Owner = IntPtr.Zero;
}
var wpfWindow = owner.Handler as IWpfWindow;
if (wpfWindow != null)
else if (owner.Handler is IWpfWindow wpfWindow)
{
// Owner could be an HwndWindowHandler (or other) which sets owner differently
wpfWindow.SetOwnerFor(Control);
}
}

public double WpfScale
{
get { return dpiHelper?.WpfScale ?? 1f; }
}
public double WpfScale => dpiHelper?.WpfScale ?? 1f;

public float LogicalPixelSize
{
Expand Down Expand Up @@ -1119,10 +1122,18 @@ public override bool Visible
set
{
if (value)
{
// set owner back if we weren't visible beforehand
SetOwner(Widget.Owner);
Control.Show();
}
else
{
// hiding will hide entire owner chain, so clear that out before making it invisible.
SetOwner(null);
Control.Hide();
}
}
}
}
}
Loading