diff options
author | Carlos Manuel Duclos Vergara <carlos.duclos@nokia.com> | 2010-05-14 09:41:05 (GMT) |
---|---|---|
committer | Carlos Manuel Duclos Vergara <carlos.duclos@nokia.com> | 2010-05-14 09:56:17 (GMT) |
commit | e0c4899b46a68b37ce743c5a1ffd17596cbaa44c (patch) | |
tree | ae1649c4ca477014ebea1cf255984ea30a04f411 /src/gui/kernel/qwidget.cpp | |
parent | 23f1fa2e47f3bd4cea92510d70c2e9d0fbbcfc92 (diff) | |
download | Qt-e0c4899b46a68b37ce743c5a1ffd17596cbaa44c.zip Qt-e0c4899b46a68b37ce743c5a1ffd17596cbaa44c.tar.gz Qt-e0c4899b46a68b37ce743c5a1ffd17596cbaa44c.tar.bz2 |
Mac: restoreGeometry()
The problem here is the fact that when zooming (maximizing) a window,
we should update the starting position since the window is now starting
at 0,0. However when restoring the window should be placed in the
original position. The bug here occurs because we kept the original
position and the new size. So the window was drawn were it was using
the new size. This patch introduces a boolean flag that keeps track of
the maximized state. We are interested in knowing if the window was
maximized but not restored, so when saving the geometry we have a way
to know that we need to "move" the window to 0,0.
Task-number: QTBUG-10504
Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e39526e..420eda6 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1581,6 +1581,11 @@ void QWidgetPrivate::createTLExtra() x->inTopLevelResize = false; x->inRepaint = false; x->embedded = 0; +#ifdef Q_WS_MAC +#ifdef QT_MAC_USE_COCOA + x->wasMaximized = false; +#endif // QT_MAC_USE_COCOA +#endif // Q_WS_MAC createTLSysExtra(); #ifdef QWIDGET_EXTRA_DEBUG static int count = 0; @@ -6749,6 +6754,18 @@ void QWidget::setGeometry(const QRect &r) */ QByteArray QWidget::saveGeometry() const { +#ifdef QT_MAC_USE_COCOA + // We check if the window was maximized during this invocation. If so, we need to record the + // starting position as 0,0. + Q_D(const QWidget); + QRect newFramePosition = frameGeometry(); + QRect newNormalPosition = normalGeometry(); + if(d->topData()->wasMaximized) { + // Change the starting position + newFramePosition.moveTo(0, 0); + newNormalPosition.moveTo(0, 0); + } +#endif // QT_MAC_USE_COCOA QByteArray array; QDataStream stream(&array, QIODevice::WriteOnly); stream.setVersion(QDataStream::Qt_4_0); @@ -6758,8 +6775,13 @@ QByteArray QWidget::saveGeometry() const stream << magicNumber << majorVersion << minorVersion +#ifdef QT_MAC_USE_COCOA + << newFramePosition + << newNormalPosition +#else << frameGeometry() << normalGeometry() +#endif // QT_MAC_USE_COCOA << qint32(QApplication::desktop()->screenNumber(this)) << quint8(windowState() & Qt::WindowMaximized) << quint8(windowState() & Qt::WindowFullScreen); |