summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-17 17:30:06 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-09 13:40:16 +0200
commitb316c3ac5e4acac75505bfd77677cecc181599af (patch)
treef51ac1f01bed8c1bf3987f1dfee1080056ac3503 /src/plugins/platforms/windows
parent465c9f4a7e89883ebe3d473b4cd4e36310884173 (diff)
Improve widget geometry.
- Rename posFromMove to posIncludesFrame in Widgets and make the handling more fine-grained; try to clean it up as soon as the frame margins are known in QWidgetPrivate::fixPosIncludesFrame(). - Implement QWidgetPrivate::updateFrameStrut(). - Windows: Handle posIncludesFrame in window creation, notify changed geometry after setting window flags. - XCB: Do not change the window gravity in propagateSizeHint() as this causes the window to jump around. Determine the gravity in window creation, leave it constant and fix the geometry when setting instead. - Store the normal geometry when maximize/fullscreen state change events are received. - Remove xfails from fixed tests Task-number: QTBUG-25331 Task-number: QTBUG-24905 Task-number: QTBUG-24294 Change-Id: I89c7229d86aaf88f02247d63915da7905e4a27ea Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp42
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h2
3 files changed, 38 insertions, 14 deletions
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 69ae653f5b..255cf1454c 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -244,8 +244,10 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
= QWindowsWindow::WindowData::create(window, requested, window->windowTitle());
if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows)
qDebug().nospace()
- << __FUNCTION__ << ' ' << window << '\n'
- << " Requested: " << requested.geometry << " Flags="
+ << __FUNCTION__ << '<' << window << '\n'
+ << " Requested: " << requested.geometry << "frame incl.: "
+ << QWindowsGeometryHint::positionIncludesFrame(window)
+ << " Flags="
<< QWindowsWindow::debugWindowFlags(requested.flags) << '\n'
<< " Obtained : " << obtained.geometry << " Margins "
<< obtained.frame << " Flags="
@@ -255,8 +257,6 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
return 0;
if (requested.flags != obtained.flags)
window->setWindowFlags(obtained.flags);
- if (requested.geometry != obtained.geometry)
- QWindowSystemInterface::handleGeometryChange(window, obtained.geometry);
return new QWindowsWindow(window, obtained);
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 87980487b7..c300f0f5a9 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -542,6 +542,12 @@ void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXI
<< " out " << *mmi;
}
+bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w)
+{
+ return qt_window_private(const_cast<QWindow *>(w))->positionPolicy
+ == QWindowPrivate::WindowFrameInclusive;
+}
+
/*!
\class QWindowCreationContext
\brief Active Context for creating windows.
@@ -576,17 +582,24 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
// CW_USEDEFAULT unless set. For now, assume that 0,0 means 'default'
// for toplevels.
if (geometry.isValid()) {
- if (!w->isTopLevel() || geometry.y() >= margins.top()) {
- frameX = geometry.x() - margins.left();
- frameY = geometry.y() - margins.top();
+ frameX = geometry.x();
+ frameY = geometry.y();
+ frameWidth = margins.left() + geometry.width() + margins.right();
+ frameHeight = margins.top() + geometry.height() + margins.bottom();
+ const bool isDefaultPosition = !frameX && !frameY && w->isTopLevel();
+ if (!QWindowsGeometryHint::positionIncludesFrame(w) && !isDefaultPosition) {
+ frameX -= margins.left();
+ frameY -= margins.top();
}
- frameWidth = geometry.width() + margins.left() + margins.right();
- frameHeight = geometry.height() + margins.top() + margins.bottom();
}
if (QWindowsContext::verboseWindows)
qDebug().nospace()
- << __FUNCTION__ << ' ' << w << " min" << geometryHint.minimumSize
- << " min" << geometryHint.maximumSize;
+ << __FUNCTION__ << ' ' << w << geometry
+ << " pos incl. frame" << QWindowsGeometryHint::positionIncludesFrame(w)
+ << " frame: " << frameWidth << 'x' << frameHeight << '+'
+ << frameX << '+' << frameY
+ << " min" << geometryHint.minimumSize
+ << " max" << geometryHint.maximumSize;
}
/*!
@@ -819,7 +832,7 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
QRect rect = rectIn;
// This means it is a call from QWindow::setFramePos() and
// the coordinates include the frame (size is still the contents rectangle).
- if (qt_window_private(window())->positionPolicy == QWindowPrivate::WindowFrameInclusive) {
+ if (QWindowsGeometryHint::positionIncludesFrame(window())) {
const QMargins margins = frameMargins();
rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top()));
}
@@ -1004,21 +1017,30 @@ Qt::WindowFlags QWindowsWindow::setWindowFlags(Qt::WindowFlags flags)
qDebug() << '>' << __FUNCTION__ << this << window() << "\n from: "
<< QWindowsWindow::debugWindowFlags(m_data.flags)
<< "\n to: " << QWindowsWindow::debugWindowFlags(flags);
+ const QRect oldGeometry = geometry();
if (m_data.flags != flags) {
m_data.flags = flags;
if (m_data.hwnd)
m_data = setWindowFlags_sys(flags);
}
+ // When switching to a frameless window, geometry
+ // may change without a WM_MOVE. Report change manually.
+ // Do not send synchronously as not to clobber the widget
+ // geometry in a sequence of setting flags and geometry.
+ const QRect newGeometry = geometry_sys();
+ if (oldGeometry != newGeometry)
+ handleGeometryChange();
+
if (QWindowsContext::verboseWindows)
qDebug() << '<' << __FUNCTION__ << "\n returns: "
- << QWindowsWindow::debugWindowFlags(m_data.flags);
+ << QWindowsWindow::debugWindowFlags(m_data.flags)
+ << " geometry " << oldGeometry << "->" << newGeometry;
return m_data.flags;
}
QWindowsWindow::WindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,
unsigned flags) const
{
- // Geometry changes have not been observed here. Frames change, though.
WindowCreationData creationData;
creationData.fromWindow(window(), wt, flags);
creationData.applyWindowFlags(m_data.hwnd);
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 87c22c76d1..64fd78d1ce 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -66,6 +66,8 @@ struct QWindowsGeometryHint
static inline QPoint mapFromGlobal(const HWND hwnd, const QPoint &);
static inline QPoint mapFromGlobal(const QWindow *w, const QPoint &);
+ static bool positionIncludesFrame(const QWindow *w);
+
QSize minimumSize;
QSize maximumSize;
};