summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2012-03-21 08:47:16 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-21 11:56:56 +0100
commit7445d41e32e5d241b5c124b7f81c0ae31c36ffc2 (patch)
treee96ba963f97835aa48b65ac01a97b058f3322773 /src
parent68d291c12a848a5737f1bcfa40079feda97a8ba5 (diff)
Cocoa: Improve window activation handling.
Make Qt window activation follow the Cocoa key window, with one exception: Popup windows become the key window but not the Qt active window. Change-Id: Ic4d8685737fa3ec5c15a68b81844929370c9cd8e Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm11
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm8
3 files changed, 15 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 0920bc7b4b..90c5a050d0 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -111,6 +111,7 @@ public:
void windowDidMove();
void windowDidResize();
void windowWillClose();
+ bool windowIsPopupType() const;
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index a76830f0b8..b4c4e31753 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -303,6 +303,15 @@ void QCocoaWindow::windowWillClose()
QWindowSystemInterface::handleSynchronousCloseEvent(window());
}
+bool QCocoaWindow::windowIsPopupType() const
+{
+ Qt::WindowType type = window()->windowType();
+ if (type == Qt::Tool)
+ return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac.
+
+ return ((type & Qt::Popup) == Qt::Popup);
+}
+
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
{
m_glContext = context;
@@ -348,7 +357,7 @@ NSWindow * QCocoaWindow::createNSWindow()
// Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
if ((type & Qt::Popup) == Qt::Popup) {
- if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::SplashScreen) {
+ if (windowIsPopupType()) {
styleMask = NSBorderlessWindowMask;
} else {
styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index ed67fd50fc..52f40ea01c 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -146,24 +146,24 @@ static QTouchDevice *touchDevice = 0;
- (void)windowDidBecomeKey
{
-// QWindowSystemInterface::handleWindowActivated(m_window);
+ if (!m_platformWindow->windowIsPopupType())
+ QWindowSystemInterface::handleWindowActivated(m_window);
}
- (void)windowDidResignKey
{
-// QWindowSystemInterface::handleWindowActivated(0);
+ if (!m_platformWindow->windowIsPopupType())
+ QWindowSystemInterface::handleWindowActivated(0);
}
- (void)windowDidBecomeMain
{
// qDebug() << "window did become main" << m_window;
- QWindowSystemInterface::handleWindowActivated(m_window);
}
- (void)windowDidResignMain
{
// qDebug() << "window did resign main" << m_window;
- QWindowSystemInterface::handleWindowActivated(0);
}