Skip to content

Commit a627fe8

Browse files
committed
ensure owner topmost flag is set if its topmost when showing a owned window
1 parent 143399f commit a627fe8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Windows/Avalonia.Win32/WindowImpl.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,8 @@ public void SetParent(IWindowImpl? parent)
708708
_hiddenWindowIsParent = parentHwnd == OffscreenParentWindow.Handle;
709709

710710
SetWindowLongPtr(_hwnd, (int)WindowLongParam.GWL_HWNDPARENT, parentHwnd);
711+
712+
(parent as WindowImpl)?.EnsureTopmost();
711713
}
712714

713715
public void SetEnabled(bool enable) => EnableWindow(_hwnd, enable);
@@ -860,6 +862,17 @@ public void SetTopmost(bool value)
860862
_topmost = value;
861863
}
862864

865+
private void EnsureTopmost()
866+
{
867+
if(_topmost)
868+
{
869+
SetWindowPos(_hwnd,
870+
WindowPosZOrder.HWND_TOPMOST,
871+
0, 0, 0, 0,
872+
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
873+
}
874+
}
875+
863876
public unsafe void SetFrameThemeVariant(PlatformThemeVariant themeVariant)
864877
{
865878
_currentThemeVariant = themeVariant;

0 commit comments

Comments
 (0)