don't change a widget's active state in QWindowsWindow::setWindowState
QWindow::setWindowState is not supposed to set the window active. The method requestActivateWindow() should be used for that. When switching from and to fullscreen mode we're always passing SWP_NOACTIVATE to SetWindowPos to not change the activation state of the window. This is inverse to the old behaviour, which did not have an effect. Change-Id: I339337935cdad76b3ef252202e92177f37543038 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
30ec535cb6
commit
a992a12bec
@ -1192,34 +1192,25 @@ bool QWindowsWindow::isFullScreen_sys() const
|
||||
|
||||
void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
{
|
||||
const Qt::WindowStates oldStates = m_windowState;
|
||||
// Maintain the active flag as the platform window API does not
|
||||
// use it.
|
||||
Qt::WindowStates newStates = newState;
|
||||
if (isActive())
|
||||
newStates |= Qt::WindowActive;
|
||||
if (oldStates == newStates)
|
||||
const Qt::WindowState &oldState = m_windowState;
|
||||
if (oldState == newState)
|
||||
return;
|
||||
if (QWindowsContext::verboseWindows)
|
||||
qDebug() << '>' << __FUNCTION__ << this << window()
|
||||
<< " from " << debugWindowStates(oldStates)
|
||||
<< " to " << debugWindowStates(newStates);
|
||||
<< " from " << debugWindowStates(oldState)
|
||||
<< " to " << debugWindowStates(newState);
|
||||
|
||||
const bool isActive = newStates & Qt::WindowActive;
|
||||
const int max = isActive ? SW_SHOWMAXIMIZED : SW_MAXIMIZE;
|
||||
const int normal = isActive ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE;
|
||||
const int min = isActive ? SW_SHOWMINIMIZED : SW_MINIMIZE;
|
||||
const bool visible = isVisible();
|
||||
|
||||
setFlag(FrameDirty);
|
||||
|
||||
if ((oldStates & Qt::WindowMaximized) != (newStates & Qt::WindowMaximized)) {
|
||||
if (visible && !(newStates & Qt::WindowMinimized))
|
||||
ShowWindow(m_data.hwnd, (newStates & Qt::WindowMaximized) ? max : normal);
|
||||
if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) {
|
||||
if (visible && !(newState == Qt::WindowMinimized))
|
||||
ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
|
||||
}
|
||||
|
||||
if ((oldStates & Qt::WindowFullScreen) != (newStates & Qt::WindowFullScreen)) {
|
||||
if (newStates & Qt::WindowFullScreen) {
|
||||
if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) {
|
||||
if (newState == Qt::WindowFullScreen) {
|
||||
#ifndef Q_FLATTEN_EXPOSE
|
||||
UINT newStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
|
||||
#else
|
||||
@ -1231,7 +1222,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
if (!m_savedStyle) {
|
||||
m_savedStyle = style();
|
||||
#ifndef Q_OS_WINCE
|
||||
if (oldStates & Qt::WindowMinimized) {
|
||||
if (oldState == Qt::WindowMinimized) {
|
||||
WINDOWPLACEMENT wp;
|
||||
wp.length = sizeof(WINDOWPLACEMENT);
|
||||
if (GetWindowPlacement(m_data.hwnd, &wp))
|
||||
@ -1250,25 +1241,21 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
setStyle(newStyle);
|
||||
|
||||
const QRect r = window()->screen()->geometry();
|
||||
UINT swpf = SWP_FRAMECHANGED;
|
||||
if (newStates & Qt::WindowActive)
|
||||
swpf |= SWP_NOACTIVATE;
|
||||
const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE;
|
||||
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
|
||||
setFlag(SynchronousGeometryChangeEvent);
|
||||
SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
|
||||
if (!wasSync)
|
||||
clearFlag(SynchronousGeometryChangeEvent);
|
||||
QWindowSystemInterface::handleSynchronousGeometryChange(window(), r);
|
||||
} else if (!(newStates & Qt::WindowMinimized)) {
|
||||
} else if (newState != Qt::WindowMinimized) {
|
||||
// Restore saved state.
|
||||
unsigned newStyle = m_savedStyle ? m_savedStyle : style();
|
||||
if (visible)
|
||||
newStyle |= WS_VISIBLE;
|
||||
setStyle(newStyle);
|
||||
|
||||
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER;
|
||||
if (newStates & Qt::WindowActive)
|
||||
swpf |= SWP_NOACTIVATE;
|
||||
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE;
|
||||
if (!m_savedFrameGeometry.isValid())
|
||||
swpf |= SWP_NOSIZE | SWP_NOMOVE;
|
||||
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
|
||||
@ -1279,20 +1266,20 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
clearFlag(SynchronousGeometryChangeEvent);
|
||||
// preserve maximized state
|
||||
if (visible)
|
||||
ShowWindow(m_data.hwnd, (newStates & Qt::WindowMaximized) ? max : normal);
|
||||
ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
|
||||
m_savedStyle = 0;
|
||||
m_savedFrameGeometry = QRect();
|
||||
}
|
||||
}
|
||||
|
||||
if ((oldStates & Qt::WindowMinimized) != (newStates & Qt::WindowMinimized)) {
|
||||
if ((oldState == Qt::WindowMinimized) != (newState == Qt::WindowMinimized)) {
|
||||
if (visible)
|
||||
ShowWindow(m_data.hwnd, (newStates & Qt::WindowMinimized) ? min :
|
||||
(newStates & Qt::WindowMaximized) ? max : normal);
|
||||
ShowWindow(m_data.hwnd, (newState == Qt::WindowMinimized) ? SW_MINIMIZE :
|
||||
(newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
|
||||
}
|
||||
if (QWindowsContext::verboseWindows)
|
||||
qDebug() << '<' << __FUNCTION__ << this << window()
|
||||
<< debugWindowStates(newStates);
|
||||
<< debugWindowStates(newState);
|
||||
}
|
||||
|
||||
void QWindowsWindow::setStyle(unsigned s) const
|
||||
|
@ -1701,22 +1701,18 @@ void tst_QWidget::activation()
|
||||
widget2.showMinimized();
|
||||
QTest::qWait(waitTime);
|
||||
|
||||
QEXPECT_FAIL("", "QTBUG-26418", Continue);
|
||||
QVERIFY(qApp->activeWindow() == &widget1);
|
||||
widget2.showMaximized();
|
||||
QTest::qWait(waitTime);
|
||||
QVERIFY(qApp->activeWindow() == &widget2);
|
||||
widget2.showMinimized();
|
||||
QTest::qWait(waitTime);
|
||||
QEXPECT_FAIL("", "QTBUG-26418", Continue);
|
||||
QVERIFY(qApp->activeWindow() == &widget1);
|
||||
widget2.showNormal();
|
||||
QTest::qWait(waitTime);
|
||||
#if 0 // QTBUG-26418, widget2 is always set to active
|
||||
#ifndef Q_OS_WINCE
|
||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||
QEXPECT_FAIL("", "MS introduced new behavior after XP", Continue);
|
||||
#endif
|
||||
#endif
|
||||
QTest::qWait(waitTime);
|
||||
QVERIFY(qApp->activeWindow() == &widget2);
|
||||
|
Loading…
Reference in New Issue
Block a user