Skip to content

Commit 7695205

Browse files
committed
win32, keep window size at all scale settings when entering and exiting fs mode.
1 parent 06c83fb commit 7695205

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Windows/Avalonia.Win32/WindowImpl.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,14 @@ private void SetFullScreen(bool fullscreen)
826826
if (fullscreen)
827827
{
828828
GetWindowRect(_hwnd, out var windowRect);
829-
_savedWindowInfo.WindowRect = windowRect;
829+
GetClientRect(_hwnd, out var clientRect);
830+
831+
clientRect.left += windowRect.left;
832+
clientRect.right += windowRect.left;
833+
clientRect.top += windowRect.top;
834+
clientRect.bottom += windowRect.top;
835+
836+
_savedWindowInfo.WindowRect = clientRect;
830837

831838
var current = GetStyle();
832839
var currentEx = GetExtendedStyle();
@@ -863,10 +870,10 @@ private void SetFullScreen(bool fullscreen)
863870
SetExtendedStyle(_savedWindowInfo.ExStyle, false);
864871

865872
// On restore, resize to the previous saved rect size.
866-
var new_rect = _savedWindowInfo.WindowRect.ToPixelRect();
873+
var newClientRect = _savedWindowInfo.WindowRect.ToPixelRect();
867874

868-
SetWindowPos(_hwnd, IntPtr.Zero, new_rect.X, new_rect.Y, new_rect.Width,
869-
new_rect.Height,
875+
SetWindowPos(_hwnd, IntPtr.Zero, newClientRect.X, newClientRect.Y, newClientRect.Width,
876+
newClientRect.Height,
870877
SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED);
871878

872879
UpdateWindowProperties(_windowProperties, true);

0 commit comments

Comments
 (0)