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

View File

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