Skip to content

Commit 0680732

Browse files
committed
[OSX] fix resize calls before window shown.
1 parent cce425b commit 0680732

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
AvnPoint lastPositionSet;
2828
NSString* _lastTitle;
2929
IAvnMenu* _mainMenu;
30+
NSSize _lastSize;
3031

3132
bool _shown;
3233
bool _inResize;
@@ -35,6 +36,7 @@
3536
{
3637
_shown = false;
3738
_inResize = false;
39+
_lastSize = NSSize { 0, 0 };
3840
_mainMenu = nullptr;
3941
BaseEvents = events;
4042
_glContext = gl;
@@ -226,9 +228,17 @@ virtual HRESULT GetClientSize(AvnSize* ret) override
226228
if(ret == nullptr)
227229
return E_POINTER;
228230

229-
auto frame = [View frame];
230-
ret->Width = frame.size.width;
231-
ret->Height = frame.size.height;
231+
if(!_shown)
232+
{
233+
ret->Width = _lastSize.width;
234+
ret->Height = _lastSize.height;
235+
}
236+
else
237+
{
238+
auto frame = [View frame];
239+
ret->Width = frame.size.width;
240+
ret->Height = frame.size.height;
241+
}
232242

233243
return S_OK;
234244
}
@@ -323,6 +333,8 @@ virtual HRESULT Resize(double x, double y, AvnPlatformResizeReason reason) overr
323333

324334
@try
325335
{
336+
_lastSize = NSSize{x,y};
337+
326338
if(!_shown)
327339
{
328340
BaseEvents->Resized(AvnSize{x,y}, reason);

0 commit comments

Comments
 (0)