Fix window state handling

There is no need to query each time the window state
from windows, as we already know in which state it is.
We are also getting state change notifications. This fixes
issues under Windows CE.

Change-Id: I69f4d5d504e2341555d9991c68e82beed2e8129c
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Andreas Holzammer 2012-07-19 11:05:18 +02:00 committed by Qt by Nokia
parent 2d504d01dc
commit a1db174ea9
2 changed files with 11 additions and 30 deletions

View File

@ -981,8 +981,9 @@ void QWindowsWindow::handleResized(int wParam)
handleGeometryChange();
break;
case SIZE_RESTORED:
if (m_windowState != Qt::WindowNoState)
handleWindowStateChange(isFullScreen_sys() ? Qt::WindowFullScreen : Qt::WindowNoState);
bool fullScreen = isFullScreen_sys();
if ((m_windowState != Qt::WindowNoState) || fullScreen)
handleWindowStateChange(fullScreen ? Qt::WindowFullScreen : Qt::WindowNoState);
handleGeometryChange();
break;
}
@ -1166,25 +1167,6 @@ Qt::WindowState QWindowsWindow::setWindowState(Qt::WindowState state)
return state;
}
Qt::WindowState QWindowsWindow::windowState_sys() const
{
if (IsIconic(m_data.hwnd))
return Qt::WindowMinimized;
if (IsZoomed(m_data.hwnd))
return Qt::WindowMaximized;
if (isFullScreen_sys())
return Qt::WindowFullScreen;
return Qt::WindowNoState;
}
Qt::WindowStates QWindowsWindow::windowStates_sys() const
{
Qt::WindowStates result = windowState_sys();
if (GetActiveWindow() == m_data.hwnd)
result |= Qt::WindowActive;
return result;
}
bool QWindowsWindow::isFullScreen_sys() const
{
return geometry_sys() == window()->screen()->geometry();
@ -1203,11 +1185,11 @@ bool QWindowsWindow::isFullScreen_sys() const
void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
{
const Qt::WindowStates oldStates = windowStates_sys();
const Qt::WindowStates oldStates = m_windowState;
// Maintain the active flag as the platform window API does not
// use it.
Qt::WindowStates newStates = newState;
if (oldStates & Qt::WindowActive)
if (isActive())
newStates |= Qt::WindowActive;
if (oldStates == newStates)
return;
@ -1239,19 +1221,21 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
// Save geometry and style to be restored when fullscreen
// is turned off again, since on Windows, it is not a real
// Window state but emulated by changing geometry and style.
#ifndef Q_OS_WINCE // there is no style under wince
if (!m_savedStyle) {
m_savedStyle = style();
#ifndef Q_OS_WINCE
if (oldStates & Qt::WindowMinimized) {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(m_data.hwnd, &wp))
m_savedFrameGeometry = qrectFromRECT(wp.rcNormalPosition);
} else {
m_savedFrameGeometry = frameGeometry_sys();
}
}
#endif
m_savedFrameGeometry = frameGeometry_sys();
#ifndef Q_OS_WINCE
}
#endif
}
if (m_savedStyle & WS_SYSMENU)
newStyle |= WS_SYSMENU;
if (visible)

View File

@ -182,9 +182,6 @@ public:
void setFrameStrutEventsEnabled(bool enabled);
bool frameStrutEventsEnabled() const { return testFlag(FrameStrutEventsEnabled); }
Qt::WindowState windowState_sys() const;
Qt::WindowStates windowStates_sys() const;
#ifdef QT_OPENGL_ES_2
EGLSurface eglSurfaceHandle() const { return m_eglSurface;}
EGLSurface ensureEglSurfaceHandle(const QWindowsEGLStaticContextPtr &staticContext, EGLConfig config);