Skip to content

Commit

Permalink
dont re-set topmost if window isn't the topmost
Browse files Browse the repository at this point in the history
  • Loading branch information
emmauss committed Jun 24, 2024
1 parent a3de918 commit 593b1c2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,18 +853,24 @@ public void SetTopmost(bool value)
return;
}

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

EnsureTopmost();
_topmost = value;
}

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);
if(_topmost)
{
SetWindowPos(_hwnd,
WindowPosZOrder.HWND_TOPMOST,
0, 0, 0, 0,
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
}
}

public unsafe void SetFrameThemeVariant(PlatformThemeVariant themeVariant)
Expand Down

0 comments on commit 593b1c2

Please sign in to comment.