summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-06-10 14:27:22 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-06-10 13:03:24 +0000
commitac2a44c716d84979747e166f43129e59612e1a97 (patch)
treebafaaeeeddcdb8744100fb7c3498b871c05241da
parent34e06b48678b60716d614281898fd4e18fb4d586 (diff)
Add QPlatformWindow::windowClosestAcceptableGeometry().
Add a function to determine the closest acceptable geometry (height-for-width) to QPlatformWindow similar to the existing QPlatformWindow::windowMinimumSize(), windowMaximumSize()... Clean up the hack in the Windows platform plugin accordingly. Change-Id: I96e943cfdbafdd0ff444e0d53ee0bdf8603d33df Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--src/gui/kernel/qplatformwindow.cpp14
-rw-r--r--src/gui/kernel/qplatformwindow.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp3
3 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 34a1fabc76..9217aca400 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -690,6 +690,20 @@ QRect QPlatformWindow::windowGeometry() const
}
/*!
+ Returns the closest acceptable geometry for a given geometry before
+ a resize/move event for platforms that support it, for example to
+ implement heightForWidth().
+*/
+QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const
+{
+ QWindow *qWindow = window();
+ const QRectF rectF = QHighDpi::fromNativePixels(nativeRect, qWindow);
+ const QRectF correctedGeometryF = qt_window_private(qWindow)->closestAcceptableGeometry(rectF);
+ return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF
+ ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
+}
+
+/*!
\class QPlatformWindow
\since 4.8
\internal
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index c1f2a4bdf1..692ae862db 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -138,6 +138,8 @@ public:
QSize windowBaseSize() const;
QSize windowSizeIncrement() const;
QRect windowGeometry() const;
+ QRectF windowClosestAcceptableGeometry(const QRectF &nativeRect) const;
+
protected:
static QString formatWindowTitle(const QString &title, const QString &separator);
QPlatformScreen *screenForGeometry(const QRect &newGeometry) const;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index d6677bb228..0f32ff1f98 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1811,8 +1811,7 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,
windowPos->cx, windowPos->cy);
const QRect suggestedGeometry = suggestedFrameGeometry - margins;
- const QRectF correctedGeometryF =
- qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(suggestedGeometry);
+ const QRectF correctedGeometryF = qWindow->handle()->windowClosestAcceptableGeometry(suggestedGeometry);
if (!correctedGeometryF.isValid())
return false;
const QRect correctedFrameGeometry = correctedGeometryF.toRect() + margins;