Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/osx flicker #6250

Merged
merged 7 commits into from
Jul 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions native/Avalonia.Native/src/OSX/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
IAvnMenu* _mainMenu;

bool _shown;
bool _inResize;

WindowBaseImpl(IAvnWindowBaseEvents* events, IAvnGlContext* gl)
{
_shown = false;
_inResize = false;
_mainMenu = nullptr;
BaseEvents = events;
_glContext = gl;
Expand Down Expand Up @@ -277,6 +279,13 @@ virtual HRESULT SetMinMaxSize (AvnSize minSize, AvnSize maxSize) override

virtual HRESULT Resize(double x, double y) override
{
if(_inResize)
{
return S_OK;
}

_inResize = true;

START_COM_CALL;

@autoreleasepool
Expand Down Expand Up @@ -304,13 +313,19 @@ virtual HRESULT Resize(double x, double y) override
y = maxSize.height;
}

if(!_shown)
@try
{
BaseEvents->Resized(AvnSize{x,y});
if(!_shown)
{
BaseEvents->Resized(AvnSize{x,y});
}

[Window setContentSize:NSSize{x, y}];
}
@finally
{
_inResize = false;
}

[StandardContainer setFrameSize:NSSize{x,y}];
[Window setContentSize:NSSize{x, y}];

return S_OK;
}
Expand Down Expand Up @@ -1277,6 +1292,9 @@ -(AutoFitContentView* _Nonnull) initWithContent:(NSView *)content
[_blurBehind setWantsLayer:true];
_blurBehind.hidden = true;

[_blurBehind setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[_content setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];

[self addSubview:_blurBehind];
[self addSubview:_content];

Expand Down Expand Up @@ -1312,9 +1330,6 @@ -(void)setFrameSize:(NSSize)newSize
_settingSize = true;
[super setFrameSize:newSize];

[_blurBehind setFrameSize:newSize];
[_content setFrameSize:newSize];

auto window = objc_cast<AvnWindow>([self window]);

// TODO get actual titlebar size
Expand All @@ -1330,6 +1345,7 @@ -(void)setFrameSize:(NSSize)newSize
[_titleBarMaterial setFrame:tbar];
tbar.size.height = height < 1 ? 0 : 1;
[_titleBarUnderline setFrame:tbar];

_settingSize = false;
}

Expand Down Expand Up @@ -2375,11 +2391,12 @@ virtual NSWindowStyleMask GetStyle() override

virtual HRESULT Resize(double x, double y) override
{
START_COM_CALL;

@autoreleasepool
{
if (Window != nullptr)
{
[StandardContainer setFrameSize:NSSize{x,y}];
[Window setContentSize:NSSize{x, y}];

[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))];
Expand Down