Browse Source

Merge pull request #6250 from AvaloniaUI/fixes/osx-red-flicker

Fixes/osx flicker
release/0.10.7
Nikita Tsukanov 5 years ago
committed by Dan Walmsley
parent
commit
f8af8d59fc
  1. 35
      native/Avalonia.Native/src/OSX/window.mm

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

@ -29,10 +29,12 @@ public:
IAvnMenu* _mainMenu; IAvnMenu* _mainMenu;
bool _shown; bool _shown;
bool _inResize;
WindowBaseImpl(IAvnWindowBaseEvents* events, IAvnGlContext* gl) WindowBaseImpl(IAvnWindowBaseEvents* events, IAvnGlContext* gl)
{ {
_shown = false; _shown = false;
_inResize = false;
_mainMenu = nullptr; _mainMenu = nullptr;
BaseEvents = events; BaseEvents = events;
_glContext = gl; _glContext = gl;
@ -258,6 +260,13 @@ public:
virtual HRESULT Resize(double x, double y) override virtual HRESULT Resize(double x, double y) override
{ {
if(_inResize)
{
return S_OK;
}
_inResize = true;
START_COM_CALL; START_COM_CALL;
@autoreleasepool @autoreleasepool
@ -285,13 +294,19 @@ public:
y = maxSize.height; 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; return S_OK;
} }
@ -1265,6 +1280,9 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
[_blurBehind setWantsLayer:true]; [_blurBehind setWantsLayer:true];
_blurBehind.hidden = true; _blurBehind.hidden = true;
[_blurBehind setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[_content setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self addSubview:_blurBehind]; [self addSubview:_blurBehind];
[self addSubview:_content]; [self addSubview:_content];
@ -1300,9 +1318,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
_settingSize = true; _settingSize = true;
[super setFrameSize:newSize]; [super setFrameSize:newSize];
[_blurBehind setFrameSize:newSize];
[_content setFrameSize:newSize];
auto window = objc_cast<AvnWindow>([self window]); auto window = objc_cast<AvnWindow>([self window]);
// TODO get actual titlebar size // TODO get actual titlebar size
@ -1318,6 +1333,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
[_titleBarMaterial setFrame:tbar]; [_titleBarMaterial setFrame:tbar];
tbar.size.height = height < 1 ? 0 : 1; tbar.size.height = height < 1 ? 0 : 1;
[_titleBarUnderline setFrame:tbar]; [_titleBarUnderline setFrame:tbar];
_settingSize = false; _settingSize = false;
} }
@ -2344,11 +2360,12 @@ protected:
virtual HRESULT Resize(double x, double y) override virtual HRESULT Resize(double x, double y) override
{ {
START_COM_CALL;
@autoreleasepool @autoreleasepool
{ {
if (Window != nullptr) if (Window != nullptr)
{ {
[StandardContainer setFrameSize:NSSize{x,y}];
[Window setContentSize:NSSize{x, y}]; [Window setContentSize:NSSize{x, y}];
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))]; [Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))];

Loading…
Cancel
Save