Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#8269 from AvaloniaUI/fixes/osx-setconte…
Browse files Browse the repository at this point in the history
…nt-size-shadow-invalidation

Fixes/osx setcontent size shadow invalidation
  • Loading branch information
danwalmsley authored Jun 3, 2022
2 parents ab0c135 + 09c9a98 commit d666e4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
1 change: 0 additions & 1 deletion native/Avalonia.Native/src/OSX/WindowBaseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ BEGIN_INTERFACE_MAP()
private:
void CreateNSWindow (bool isDialog);
void CleanNSWindow ();
void InitialiseNSWindow ();

NSCursor *cursor;
ComPtr<IAvnGlContext> _glContext;
Expand Down
41 changes: 13 additions & 28 deletions native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@
lastMenu = nullptr;

CreateNSWindow(usePanel);
InitialiseNSWindow();

[Window setContentView:StandardContainer];
[Window setStyleMask:NSWindowStyleMaskBorderless];
[Window setBackingType:NSBackingStoreBuffered];

[Window setContentMinSize:lastMinSize];
[Window setContentMaxSize:lastMaxSize];

[Window setOpaque:false];
[Window setHasShadow:true];
}

HRESULT WindowBaseImpl::ObtainNSViewHandle(void **ret) {
Expand Down Expand Up @@ -89,6 +98,8 @@
START_COM_CALL;

@autoreleasepool {
[Window setContentSize:lastSize];

if(hasPosition)
{
SetPosition(lastPositionSet);
Expand Down Expand Up @@ -291,8 +302,7 @@
if (!_shown) {
BaseEvents->Resized(AvnSize{x, y}, reason);
}

if(Window != nullptr) {
else if(Window != nullptr) {
[Window setContentSize:lastSize];
[Window invalidateShadow];
}
Expand Down Expand Up @@ -568,31 +578,6 @@
}
}

void WindowBaseImpl::InitialiseNSWindow() {
if(Window != nullptr) {
[Window setContentView:StandardContainer];
[Window setStyleMask:NSWindowStyleMaskBorderless];
[Window setBackingType:NSBackingStoreBuffered];

[Window setContentSize:lastSize];
[Window setContentMinSize:lastMinSize];
[Window setContentMaxSize:lastMaxSize];

[Window setOpaque:false];

[Window setHasShadow:true];
[Window invalidateShadow];

if (lastMenu != nullptr) {
[GetWindowProtocol() applyMenu:lastMenu];

if ([Window isKeyWindow]) {
[GetWindowProtocol() showWindowMenuWithAppMenu];
}
}
}
}

id <AvnWindowProtocol> WindowBaseImpl::GetWindowProtocol() {
if(Window == nullptr)
{
Expand Down
5 changes: 0 additions & 5 deletions native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
[GetWindowProtocol() setIsExtended:true];
SetExtendClientArea(true);
}

if(_parent != nullptr)
{
SetParent(_parent);
}
}

HRESULT WindowImpl::Show(bool activate, bool isDialog) {
Expand Down

0 comments on commit d666e4f

Please sign in to comment.