diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-02-07 09:27:56 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-13 16:18:44 (GMT) |
commit | d38ae7ea322bedb16045d0dc4a71498fadfb2dd9 (patch) | |
tree | 056accca53694ee66b42f5c8b3a74cdc687a169a /src | |
parent | a85849604239034742c47d5be628122bae825c9e (diff) | |
download | Qt-d38ae7ea322bedb16045d0dc4a71498fadfb2dd9.zip Qt-d38ae7ea322bedb16045d0dc4a71498fadfb2dd9.tar.gz Qt-d38ae7ea322bedb16045d0dc4a71498fadfb2dd9.tar.bz2 |
Windows: Restore maximized/full screen widgets to correct screen.
Partially revert 54865d47cfd859a0e84ba8e1bbff3b56c93d4e0d and
bring back parts from abba37cd0eff959edf2d011842cbf2b36cce8467 which
failed some tests on other platforms and never made it in.
Avoid setting a geometry on maximized windows since that leaves
them in a broken state. Instead, if there is a need to restore
maximized windows to a different screen, clear the maximized flag
before applying the geometry.
[ChangeLog][QWidget][Windows] QWidget::restoreGeometry() now restores
maximized/full screen widgets to the correct screen.
Task-number: QTBUG-21371
Task-number: QTBUG-4397
Change-Id: Ibd5b736e921f20d4b7365c06c6f9c5dd4469c781
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
(cherry picked from qtbase/ae4243df1e53b0aaeada708f6fa7979a0f0d216a)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 53c1d3f..de7a4a1 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7139,12 +7139,25 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) if (maximized || fullScreen) { // set geomerty before setting the window state to make // sure the window is maximized to the right screen. - // Skip on windows: the window is restored into a broken - // half-maximized state. + Qt::WindowStates ws = windowState(); #ifndef Q_WS_WIN setGeometry(restoredNormalGeometry); -#endif - Qt::WindowStates ws = windowState(); +#else + if (ws & Qt::WindowFullScreen) { + // Full screen is not a real window state on Windows. + move(availableGeometry.topLeft()); + } else if (ws & Qt::WindowMaximized) { + // Setting a geometry on an already maximized window causes this to be + // restored into a broken, half-maximized state, non-resizable state (QTBUG-4397). + // Move the window in normal state if needed. + if (restoredScreenNumber != desktop->screenNumber(this)) { + setWindowState(Qt::WindowNoState); + setGeometry(restoredNormalGeometry); + } + } else { + setGeometry(restoredNormalGeometry); + } +#endif // Q_WS_WIN if (maximized) ws |= Qt::WindowMaximized; if (fullScreen) |