1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

[macOS] Fix global popover clipping. (#3264)

* [macOS] Fix global popover clipping.

Fixes #3263

* [macOS] Detach global popover via ugly hack.
This commit is contained in:
Dzmitry Neviadomski 2022-06-13 20:26:30 +03:00 committed by GitHub
parent 955091ce12
commit f8264ce957
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -248,6 +248,7 @@ typedef NS_ENUM(unsigned int, addType) { //
@property(nonatomic) URLSheetWindowController* fUrlSheetController;
@property(nonatomic) BOOL fGlobalPopoverShown;
@property(nonatomic) NSView* fPositioningView;
@property(nonatomic) BOOL fSoundPlaying;
@property(nonatomic) id fNoNapActivity;

View file

@ -3100,7 +3100,21 @@ static void removeKeRangerRansomware()
popover.delegate = self;
NSView* senderView = sender;
[popover showRelativeToRect:senderView.frame ofView:senderView preferredEdge:NSMaxYEdge];
CGFloat width = NSWidth(senderView.frame);
if (NSMinX(self.fWindow.frame) < width || NSMaxX(self.fWindow.screen.frame) - NSMinX(self.fWindow.frame) < width * 2)
{
// Ugly hack to hide NSPopover arrow.
self.fPositioningView = [[NSView alloc] initWithFrame:senderView.bounds];
self.fPositioningView.identifier = @"positioningView";
[senderView addSubview:self.fPositioningView];
[popover showRelativeToRect:self.fPositioningView.bounds ofView:self.fPositioningView preferredEdge:NSMaxYEdge];
self.fPositioningView.bounds = NSOffsetRect(self.fPositioningView.bounds, 0, NSHeight(self.fPositioningView.bounds));
}
else
{
[popover showRelativeToRect:senderView.frame ofView:senderView preferredEdge:NSMaxYEdge];
}
}
//don't show multiple popovers when clicking the gear button repeatedly
@ -3109,8 +3123,9 @@ static void removeKeRangerRansomware()
self.fGlobalPopoverShown = YES;
}
- (void)popoverWillClose:(NSNotification*)notification
- (void)popoverDidClose:(NSNotification*)notification
{
[self.fPositioningView removeFromSuperview];
self.fGlobalPopoverShown = NO;
}