Cocoa: fix window focus lost when opening combobox
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>
Tue, 23 Oct 2012 09:33:47 +0000 (11:33 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 12 Nov 2012 16:38:06 +0000 (17:38 +0100)
In cocoa, saying that a panel accepts key events, will make it receive
key events, but also show it as the active window on screen. The former
we dont really have to care about, since Qt will take care of forwarding
events to the popup for us anyway, even when they target another window.
So the only reason to actually let a panel become key window, is when
we want it to become active. And for popups, we only want this to happend
for Tool windows.

Change-Id: Ic4e5058307c514cbe30174d2a2d4ca0f41c8f71f
QTBUG: 26598
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
src/plugins/platforms/cocoa/qcocoawindow.mm

index a762603..d17df81 100644 (file)
@@ -148,12 +148,10 @@ static bool isMouseEvent(NSEvent *ev)
 
 - (BOOL)canBecomeKeyWindow
 {
-    // Most panels can be come the key window. Exceptions are:
-    if (m_cocoaPlatformWindow->window()->type() == Qt::ToolTip)
-        return NO;
-    if (m_cocoaPlatformWindow->window()->type() == Qt::SplashScreen)
-        return NO;
-    return YES;
+    // Only tool windows should become key for popup types:
+    if (m_cocoaPlatformWindow->window()->type() == Qt::Tool)
+        return YES;
+    return NO;
 }
 
 - (void) sendEvent: (NSEvent*) theEvent