Revert "OS X: main window doesn't become key."

This reverts commit da0c74550f.
The patch da0c74 unfortunately does not work well with QCocoaMenuBar's logic:
it can happen that our selectNextKeyWindow chooses a Popup or another window with
some 'unusual' flag as a key, but QCocoaMenuBar::updateMenuBarImmediately will return
immediately, assuming that popup does not have a menu and there are no menu items to enable.

Task-number: QTBUG-44369
Change-Id: I83cd2f6a62acd3a6ceb4d9dbf53ca42af67476d8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Timur Pocheptsov 2015-02-17 17:19:42 +01:00
parent 14fdd946f6
commit 5bf9528b91

View File

@ -82,31 +82,6 @@ static bool isMouseEvent(NSEvent *ev)
}
}
static void selectNextKeyWindow(NSWindow *currentKeyWindow)
{
if (!currentKeyWindow)
return;
const QCocoaAutoReleasePool pool;
if ([[NSApplication sharedApplication] keyWindow] != currentKeyWindow)
return;//currentKeyWindow is not a key window actually.
NSArray *const windows = [[NSApplication sharedApplication] windows];
bool startLookup = false;
for (NSWindow *candidate in [windows reverseObjectEnumerator]) {
if (!startLookup) {
if (candidate == currentKeyWindow)
startLookup = true;
} else {
if ([candidate isVisible] && [candidate canBecomeKeyWindow]) {
[candidate makeKeyWindow];
break;
}
}
}
}
@implementation QNSWindowHelper
@synthesize window = _window;
@ -599,9 +574,6 @@ void QCocoaWindow::hide(bool becauseOfAncestor)
foreach (QCocoaWindow *childWindow, m_childWindows)
childWindow->hide(true);
if (window()->transientParent() && m_nsWindow == [[NSApplication sharedApplication] keyWindow])
selectNextKeyWindow(m_nsWindow); // Otherwise, Cocoa can do it wrong.
[m_nsWindow orderOut:nil];
}