QWidget/Win: fix restoreGeometry() from fullscreen mode
When turning off fullscreen mode and restoring the widget's geometry we must inform the QWindow about the geometry change synchronously. Otherwise QWidget::geometry() will return the old value. Using the same technique for the state transition to fullscreen mode without sending a separate resize event. Autotest: tst_QWidget::saveRestoreGeometry Task-number: QTBUG-26421 Change-Id: I869e36cd302d9a94e398f48949ab3cb7ee9cdf51 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
85d664c929
commit
af8e318b35
@ -993,7 +993,10 @@ void QWindowsWindow::handleGeometryChange()
|
||||
{
|
||||
m_data.geometry = geometry_sys();
|
||||
QPlatformWindow::setGeometry(m_data.geometry);
|
||||
QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
|
||||
if (testFlag(SynchronousGeometryChangeEvent))
|
||||
QWindowSystemInterface::handleSynchronousGeometryChange(window(), m_data.geometry);
|
||||
else
|
||||
QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
|
||||
|
||||
if (QWindowsContext::verboseEvents || QWindowsContext::verboseWindows)
|
||||
qDebug() << __FUNCTION__ << this << window() << m_data.geometry;
|
||||
@ -1246,7 +1249,11 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
UINT swpf = SWP_FRAMECHANGED;
|
||||
if (newStates & Qt::WindowActive)
|
||||
swpf |= 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)) {
|
||||
// Restore saved state.
|
||||
@ -1260,8 +1267,12 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
|
||||
swpf |= SWP_NOACTIVATE;
|
||||
if (!m_savedFrameGeometry.isValid())
|
||||
swpf |= SWP_NOSIZE | SWP_NOMOVE;
|
||||
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
|
||||
setFlag(SynchronousGeometryChangeEvent);
|
||||
SetWindowPos(m_data.hwnd, 0, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(),
|
||||
m_savedFrameGeometry.width(), m_savedFrameGeometry.height(), swpf);
|
||||
if (!wasSync)
|
||||
clearFlag(SynchronousGeometryChangeEvent);
|
||||
// preserve maximized state
|
||||
if (visible)
|
||||
ShowWindow(m_data.hwnd, (newStates & Qt::WindowMaximized) ? max : normal);
|
||||
|
@ -124,7 +124,8 @@ public:
|
||||
OpenGlPixelFormatInitialized = 0x40,
|
||||
BlockedByModal = 0x80,
|
||||
SizeGripOperation = 0x100,
|
||||
FrameStrutEventsEnabled = 0x200
|
||||
FrameStrutEventsEnabled = 0x200,
|
||||
SynchronousGeometryChangeEvent = 0x400
|
||||
};
|
||||
|
||||
struct WindowData
|
||||
|
@ -2945,9 +2945,6 @@ void tst_QWidget::saveRestoreGeometry()
|
||||
QVERIFY(widget.restoreGeometry(savedGeometry));
|
||||
QTest::qWait(120);
|
||||
QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen));
|
||||
#ifdef Q_OS_WIN
|
||||
QEXPECT_FAIL("", "QTBUG-26421", Continue);
|
||||
#endif
|
||||
QTRY_COMPARE(widget.geometry(), geom);
|
||||
|
||||
//Restore to full screen
|
||||
|
Loading…
Reference in New Issue
Block a user