Cocoa: Fix beep-on-show for Creator menus.

Maintain a current window state variable in QCocoaWindnow
and use it when setting the new window state on the
NSWindow.

The NSWindow state accessors can apparently not be
trusted, in particular isZoomed always returns true
for the Creator popup menu.

Change-Id: I78f13de251f3730752813bba17459011f8558aee
Reviewed-by: James Turner <james.turner@kdab.com>
Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Morten Johan Sorvig 2012-04-26 12:29:01 +02:00 committed by Qt by Nokia
parent b7cd964761
commit 4e59daf34f
2 changed files with 25 additions and 34 deletions

View File

@ -140,6 +140,7 @@ public: // for QNSView
QNSView *m_contentView;
NSWindow *m_nsWindow;
Qt::WindowFlags m_windowFlags;
Qt::WindowState m_synchedWindowState;
QPointer<QWindow> m_activePopupWindow;
bool m_inConstructor;

View File

@ -97,6 +97,7 @@
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
, m_nsWindow(0)
, m_synchedWindowState(Qt::WindowActive)
, m_inConstructor(true)
, m_glContext(0)
, m_hasModalSession(false)
@ -543,41 +544,30 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
if (!m_nsWindow)
return;
switch (newState) {
case Qt::WindowMinimized:
[m_nsWindow performMiniaturize : m_nsWindow];
break;
case Qt::WindowMaximized:
[m_nsWindow performZoom : m_nsWindow];
break;
case Qt::WindowFullScreen:
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
[m_nsWindow toggleFullScreen : m_nsWindow];
} else {
qWarning("Not implemented: setWindowState WindowFullScreen");
}
#endif
break;
default:
// Undo current states
if ([m_nsWindow isMiniaturized])
[m_nsWindow deminiaturize : m_nsWindow];
if ([m_nsWindow isZoomed])
[m_nsWindow performZoom : m_nsWindow]; // toggles
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
if (window()->windowState() & Qt::WindowFullScreen)
[m_nsWindow toggleFullScreen : m_nsWindow];
} else {
qWarning("Not implemented: setWindowState WindowFullScreen");
}
#endif
break;
if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized)) {
[m_nsWindow performZoom : m_nsWindow]; // toggles
}
if ((m_synchedWindowState & Qt::WindowMinimized) != (newState & Qt::WindowMinimized)) {
if (newState & Qt::WindowMinimized) {
[m_nsWindow performMiniaturize : m_nsWindow];
} else {
[m_nsWindow deminiaturize : m_nsWindow];
}
}
if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
[m_nsWindow toggleFullScreen : m_nsWindow];
} else {
// TODO: "normal" fullscreen
}
#endif
}
// New state is now the current synched state
m_synchedWindowState = newState;
}
bool QCocoaWindow::setWindowModified(bool modified)