Skip to content

Commit

Permalink
Merge pull request #5943 from AvaloniaUI/fixes/missing-osx-shadow-border
Browse files Browse the repository at this point in the history
trick to make OSX invalidate the shadow.
  • Loading branch information
Dan Walmsley committed May 19, 2021
1 parent 55758e3 commit 2364f66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions native/Avalonia.Native/src/OSX/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class WindowBaseImpl;
-(double) getScaling;
-(double) getExtendedTitleBarHeight;
-(void) setIsExtended:(bool)value;
-(void) updateShadow;
@end

struct INSWindowHolder
Expand Down
19 changes: 18 additions & 1 deletion native/Avalonia.Native/src/OSX/window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ virtual HRESULT Show(bool activate) override
[Window setTitle:_lastTitle];

_shown = true;


dispatch_async(dispatch_get_main_queue(), ^{
[Window updateShadow];
});

return S_OK;
}
}
Expand Down Expand Up @@ -1838,6 +1842,19 @@ @implementation AvnWindow
double _lastScaling;
}

- (void)updateShadow
{
// Common problem in Cocoa where [invalidateShadow] does work,
// This hack forces Cocoa to invalidate the shadow.

NSRect frame = [self frame];
NSRect updatedFrame = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width + 1.0, frame.size.height + 1.0);
[self setFrame:updatedFrame display:YES];
[self setFrame:frame display:YES];

[self invalidateShadow];
}

-(void) setIsExtended:(bool)value;
{
_isExtended = value;
Expand Down

0 comments on commit 2364f66

Please sign in to comment.