Merge remote-tracking branch 'origin/master' into autolayout

This commit is contained in:
Josh Vera 2014-06-19 18:16:41 -04:00
Родитель 9687f30d6b 85a5bd8cee
Коммит c3c8a99cc2
1 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -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];
@ -385,7 +386,17 @@ static CGFloat RBLRectsGetMedianY(CGRect r1, CGRect r2) {
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
//***************************************************************************