Browse Source

fix screen centering on OSX before window has been shown.

pull/5963/head
Dan Walmsley 5 years ago
parent
commit
99cdff2d70
  1. 21
      native/Avalonia.Native/src/OSX/window.mm
  2. 6
      src/Avalonia.Controls/Window.cs

21
native/Avalonia.Native/src/OSX/window.mm

@ -25,6 +25,7 @@ public:
ComPtr<IAvnGlContext> _glContext;
NSObject<IRenderTarget>* renderTarget;
AvnPoint lastPositionSet;
CGSize _lastRequestedSize;
NSString* _lastTitle;
IAvnMenu* _mainMenu;
@ -193,9 +194,18 @@ public:
{
if(ret == nullptr)
return E_POINTER;
auto frame = [View frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
if(_shown)
{
auto frame = [View frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
}
else
{
ret->Width = _lastRequestedSize.width;
ret->Height = _lastRequestedSize.height;
}
return S_OK;
}
}
@ -256,6 +266,9 @@ public:
y = maxSize.height;
}
_lastRequestedSize.width = x;
_lastRequestedSize.height = y;
[Window setContentSize:NSSize{x, y}];
return S_OK;
@ -530,7 +543,7 @@ private:
_decorations = SystemDecorationsFull;
_transitioningWindowState = false;
_inSetWindowState = false;
_lastWindowState = Normal;
_lastWindowState = (AvnWindowState)-1;
WindowEvents = events;
[Window setCanBecomeKeyAndMain];
[Window disableCursorRects];

6
src/Avalonia.Controls/Window.cs

@ -653,7 +653,11 @@ namespace Avalonia.Controls
{
using (BeginAutoSizing())
{
PlatformImpl?.Resize(initialSize);
if (PlatformImpl != null)
{
PlatformImpl.Resize(initialSize);
ClientSize = PlatformImpl.ClientSize;
}
}
}

Loading…
Cancel
Save