From 6b61e97063fcd2abf7b61b01f6686cadf818eab3 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 23 Oct 2012 11:33:47 +0200 Subject: [PATCH] Cocoa: fix window focus lost when opening combobox 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 --- src/plugins/platforms/cocoa/qcocoawindow.mm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a762603..d17df81 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -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 -- 2.7.4