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

trick to make OSX invalidate the shadow. #5943

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
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