diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index cc588284b..89aad865e 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -860,12 +860,11 @@ CPRunContinuesResponse = -1002; if ([windowController respondsToSelector:anAction]) return windowController; - + var theDocument = [windowController document]; - - if (theDocument != delegate && [theDocument respondsToSelector:anAction]) + if (theDocument !== delegate && [theDocument respondsToSelector:anAction]) return theDocument; - + return nil; } @@ -1063,7 +1062,7 @@ CPRunContinuesResponse = -1002; else if ([self mainWindow]) [[self mainWindow] makeKeyAndOrderFront:self]; else - [[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work + [[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work _previousKeyWindow = nil; _previousMainWindow = nil; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 11d029994..60374a846 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1497,7 +1497,8 @@ CPTexturedBackgroundWindowMask if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)]) [_firstResponder resignKeyWindow]; - CPApp._keyWindow = nil; + if (CPApp._keyWindow === self) + CPApp._keyWindow = nil; [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResignKeyNotification @@ -1858,7 +1859,8 @@ CPTexturedBackgroundWindowMask postNotificationName:CPWindowDidResignMainNotification object:self]; - CPApp._mainWindow = nil; + if (CPApp._mainWindow === self) + CPApp._mainWindow = nil; } - (void)_updateMainAndKeyWindows @@ -1866,9 +1868,6 @@ CPTexturedBackgroundWindowMask var allWindows = [CPApp orderedWindows], windowCount = [allWindows count]; - if (!windowCount) - return; - if ([self isKeyWindow]) { var keyWindow = [CPApp keyWindow]; @@ -1893,11 +1892,10 @@ CPTexturedBackgroundWindowMask } if (![CPApp keyWindow]) - [keyWindow makeKeyWindow]; + [menuWindow makeKeyWindow]; } } - if ([self isMainWindow]) { var mainWindow = [CPApp mainWindow];