diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 625ac09175a..a72d85b3645 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -826,7 +826,14 @@ private void SetFullScreen(bool fullscreen) if (fullscreen) { GetWindowRect(_hwnd, out var windowRect); - _savedWindowInfo.WindowRect = windowRect; + GetClientRect(_hwnd, out var clientRect); + + clientRect.left += windowRect.left; + clientRect.right += windowRect.left; + clientRect.top += windowRect.top; + clientRect.bottom += windowRect.top; + + _savedWindowInfo.WindowRect = clientRect; var current = GetStyle(); var currentEx = GetExtendedStyle(); @@ -863,10 +870,10 @@ private void SetFullScreen(bool fullscreen) SetExtendedStyle(_savedWindowInfo.ExStyle, false); // On restore, resize to the previous saved rect size. - var new_rect = _savedWindowInfo.WindowRect.ToPixelRect(); + var newClientRect = _savedWindowInfo.WindowRect.ToPixelRect(); - SetWindowPos(_hwnd, IntPtr.Zero, new_rect.X, new_rect.Y, new_rect.Width, - new_rect.Height, + SetWindowPos(_hwnd, IntPtr.Zero, newClientRect.X, newClientRect.Y, newClientRect.Width, + newClientRect.Height, SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED); UpdateWindowProperties(_windowProperties, true);