зеркало из https://github.com/github/Rebel.git
Merge remote-tracking branch 'origin/master' into autolayout
This commit is contained in:
Коммит
c3c8a99cc2
|
@ -330,7 +330,8 @@ static CGFloat RBLRectsGetMedianY(CGRect r1, CGRect r2) {
|
|||
if (strongSelf.behavior == RBLPopoverBehaviorTransient) {
|
||||
shouldClose = !mouseInPopoverWindow;
|
||||
} else {
|
||||
shouldClose = strongSelf.popoverWindow.parentWindow.isKeyWindow && NSPointInRect(NSEvent.mouseLocation, strongSelf.popoverWindow.parentWindow.frame) && !mouseInPopoverWindow;
|
||||
BOOL inParentWindow = NSPointInRect(NSEvent.mouseLocation, strongSelf.popoverWindow.parentWindow.frame);
|
||||
shouldClose = strongSelf.popoverWindow.parentWindow.isKeyWindow && inParentWindow && !mouseInPopoverWindow;
|
||||
}
|
||||
|
||||
if (shouldClose) [strongSelf close];
|
||||
|
@ -384,8 +385,18 @@ static CGFloat RBLRectsGetMedianY(CGRect r1, CGRect r2) {
|
|||
closeButton.target = self;
|
||||
closeButton.action = @selector(performClose:);
|
||||
[self.popoverWindow.contentView addSubview:closeButton];
|
||||
|
||||
[positioningView.window addChildWindow:self.popoverWindow ordered:NSWindowAbove];
|
||||
|
||||
NSWindow *topmostParentWindow = positioningView.window;
|
||||
while (topmostParentWindow.parentWindow != nil) {
|
||||
topmostParentWindow = topmostParentWindow.parentWindow;
|
||||
}
|
||||
|
||||
if (self.behavior != RBLPopoverBehaviorApplicationDefined) {
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(fullScreenChanged:) name:NSWindowWillEnterFullScreenNotification object:topmostParentWindow];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(fullScreenChanged:) name:NSWindowWillExitFullScreenNotification object:topmostParentWindow];
|
||||
}
|
||||
|
||||
[topmostParentWindow addChildWindow:self.popoverWindow ordered:NSWindowAbove];
|
||||
[self.popoverWindow makeKeyAndOrderFront:self];
|
||||
|
||||
void (^postDisplayBlock)(void) = ^{
|
||||
|
@ -443,12 +454,23 @@ static CGFloat RBLRectsGetMedianY(CGRect r1, CGRect r2) {
|
|||
self.transientEventMonitors = nil;
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:NSApplicationDidResignActiveNotification object:NSApp];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:NSWindowDidResignKeyNotification object:nil];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:NSWindowWillEnterFullScreenNotification object:nil];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:NSWindowWillExitFullScreenNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)appResignedActive:(NSNotification *)notification {
|
||||
if (self.behavior == RBLPopoverBehaviorTransient) [self close];
|
||||
}
|
||||
|
||||
- (void)fullScreenChanged:(NSNotification *)notification {
|
||||
// Turn off animations. We want the close to be instantaneous since the
|
||||
// parent window's going to be animating too.
|
||||
BOOL shouldAnimate = self.animates;
|
||||
self.animates = NO;
|
||||
[self close];
|
||||
self.animates = shouldAnimate;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//***************************************************************************
|
||||
|
|
Загрузка…
Ссылка в новой задаче