Skip to content

Commit

Permalink
ensure owner topmost is flag if it's topmost when showing a owned window
Browse files Browse the repository at this point in the history
  • Loading branch information
emmauss committed Jun 24, 2024
1 parent 143399f commit a3de918
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,8 @@ public void SetParent(IWindowImpl? parent)
_hiddenWindowIsParent = parentHwnd == OffscreenParentWindow.Handle;

SetWindowLongPtr(_hwnd, (int)WindowLongParam.GWL_HWNDPARENT, parentHwnd);

(parent as WindowImpl)?.EnsureTopmost();
}

public void SetEnabled(bool enable) => EnableWindow(_hwnd, enable);
Expand Down Expand Up @@ -851,13 +853,18 @@ public void SetTopmost(bool value)
return;
}

IntPtr hWndInsertAfter = value ? WindowPosZOrder.HWND_TOPMOST : WindowPosZOrder.HWND_NOTOPMOST;
_topmost = value;

EnsureTopmost();
}

private void EnsureTopmost()
{
IntPtr hWndInsertAfter = _topmost ? WindowPosZOrder.HWND_TOPMOST : WindowPosZOrder.HWND_NOTOPMOST;
SetWindowPos(_hwnd,
hWndInsertAfter,
0, 0, 0, 0,
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);

_topmost = value;
}

public unsafe void SetFrameThemeVariant(PlatformThemeVariant themeVariant)
Expand Down

0 comments on commit a3de918

Please sign in to comment.