Browse Source

[Avalonia.Native] Fix fullscreen transitions with ExtendClientAreaToDecorationsHint windows (#19939)

backports/19939
Tim Miller 3 months ago
committed by Timothy Miller
parent
commit
4f3a010d0b
  1. 37
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  2. 4
      native/Avalonia.Native/src/OSX/WindowImpl.h

37
native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -436,23 +436,28 @@
return;
}
// If the window has been moved into a position where it's "zoomed"
// Then it should be set as Maximized.
if (window->WindowState() != Maximized && window->IsZoomed())
// Don't adjust window state during fullscreen transitions
// as this can interfere with proper decoration restoration
if(!window->IsTransitioningWindowState())
{
window->SetWindowState(Maximized, false);
}
// We should only return the window state to normal if
// the internal window state is maximized, and macOS says
// the window is no longer zoomed (I.E, the user has moved it)
// Stage Manager will "move" the window when repositioning it
// So if the window was "maximized" before, it should stay maximized
else if(window->WindowState() == Maximized && !window->IsZoomed())
{
// If we're moving the window while maximized,
// we need to let macOS handle if it should be resized
// And not handle it ourselves.
window->SetWindowState(Normal, false);
// If the window has been moved into a position where it's "zoomed"
// Then it should be set as Maximized.
if (window->WindowState() != Maximized && window->IsZoomed())
{
window->SetWindowState(Maximized, false);
}
// We should only return the window state to normal if
// the internal window state is maximized, and macOS says
// the window is no longer zoomed (I.E, the user has moved it)
// Stage Manager will "move" the window when repositioning it
// So if the window was "maximized" before, it should stay maximized
else if(window->WindowState() == Maximized && !window->IsZoomed())
{
// If we're moving the window while maximized,
// we need to let macOS handle if it should be resized
// And not handle it ourselves.
window->SetWindowState(Normal, false);
}
}
}

4
native/Avalonia.Native/src/OSX/WindowImpl.h

@ -87,7 +87,9 @@ BEGIN_INTERFACE_MAP()
bool CanBecomeKeyWindow ();
bool CanZoom() override { return _isEnabled && _canMaximize; }
bool IsTransitioningWindowState() { return _transitioningWindowState; }
protected:
virtual NSWindowStyleMask CalculateStyleMask() override;
virtual void UpdateAppearance() override;

Loading…
Cancel
Save