Cocoa: Make sure we update internal window fullscreen state

We update the internal/synched state by assigning it its QWindow's
state. Since that one is not a flag, it can only be in one state at
a time, meaning that we may lose the maximized state (but we've been
losing it for some time).

Task-number: QTBUG-30139
Change-Id: Idf30713c6ae912cafe3bbdd7be18214cf4de34f7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
bb10
Gabriel de Dietrich 2013-06-03 18:29:56 +02:00 committed by The Qt Project
parent 3b5954e405
commit 7ee15bfbb8
3 changed files with 17 additions and 4 deletions

View File

@ -136,6 +136,8 @@ public:
bool windowShouldClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
void setSynchedWindowStateFromWindow();
NSInteger windowLevel(Qt::WindowFlags flags);
NSUInteger windowStyleMask(Qt::WindowFlags flags);
void setWindowShadow(Qt::WindowFlags flags);

View File

@ -725,6 +725,12 @@ bool QCocoaWindow::windowShouldClose()
return accepted;
}
void QCocoaWindow::setSynchedWindowStateFromWindow()
{
if (QWindow *w = window())
m_synchedWindowState = w->windowState();
}
bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
{
if (type == Qt::Widget)

View File

@ -290,10 +290,15 @@ static QTouchDevice *touchDevice = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
if (notificationName == NSWindowDidEnterFullScreenNotification) {
QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowFullScreen);
} else if (notificationName == NSWindowDidExitFullScreenNotification) {
QWindowSystemInterface::handleWindowStateChanged(m_window, Qt::WindowNoState);
if (notificationName == NSWindowDidEnterFullScreenNotification
|| notificationName == NSWindowDidExitFullScreenNotification) {
Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
Qt::WindowFullScreen : Qt::WindowNoState;
QWindowSystemInterface::handleWindowStateChanged(m_window, newState);
// We want to read the window state back from the window,
// but the event we just sent may be asynchronous.
QWindowSystemInterface::flushWindowSystemEvents();
m_platformWindow->setSynchedWindowStateFromWindow();
}
}
#endif