Skip to content

Commit

Permalink
win32, keep window size at all scale settings when entering and exiti…
Browse files Browse the repository at this point in the history
…ng fs mode.
  • Loading branch information
danwalmsley committed Jul 6, 2022
1 parent 06c83fb commit 7695205
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7695205

Please sign in to comment.