summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-08 14:32:18 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2016-02-09 18:04:12 +0000
commitf5b9cdbb0844dd149d9b945b28da42d56977f844 (patch)
treecff6c1a60965eca3ee57681490915ded36478948
parent4c1b6cdd292bc571a4104fff8b5b54d47970cca1 (diff)
downloadqtbase-f5b9cdbb0844dd149d9b945b28da42d56977f844.tar.gz
HighDPI: Extend exposed region to avoid artifacts by rounding.
Introduce a special scaling function fromNativeLocalExposedRegion() for exposed regions that uses the floor of the top left point and the ceiling of the bottom right point similarly to how it was done in the XCB plugin in 5.5. Task-number: QTBUG-46615 Task-number: QTBUG-50463 Change-Id: I95e4a571b814357c014605ed79e374a821fa155b Reviewed-by: Błażej Szczygieł <spaz16@wp.pl> Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h21
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp3
2 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 9e33787f53..fac3ae420d 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -47,6 +47,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qmargins.h>
+#include <QtCore/qmath.h>
#include <QtCore/qrect.h>
#include <QtCore/qvector.h>
#include <QtCore/qloggingcategory.h>
@@ -382,6 +383,24 @@ inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow *
return pointRegion;
}
+// When mapping expose events to Qt rects: round top/left towards the origin and
+// bottom/right away from the origin, making sure that we cover the whole window.
+inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QWindow *window)
+{
+ if (!QHighDpiScaling::isActive())
+ return pixelRegion;
+
+ const qreal scaleFactor = QHighDpiScaling::factor(window);
+ QRegion pointRegion;
+ foreach (const QRect &rect, pixelRegion.rects()) {
+ const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor;
+ const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor;
+ pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
+ QPoint(qCeil(bottomRightP.x()), qCeil(bottomRightP.y())));
+ }
+ return pointRegion;
+}
+
inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
{
if (!QHighDpiScaling::isActive())
@@ -498,6 +517,8 @@ namespace QHighDpi {
template <typename T> inline
T fromNativeLocalRegion(const T &value, ...) { return value; }
template <typename T> inline
+ T fromNativeLocalExposedRegion(const T &value, ...) { return value; }
+ template <typename T> inline
T toNativeLocalRegion(const T &value, ...) { return value; }
template <typename T> inline
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 4bbc303ac0..e10ddf22a7 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -582,7 +582,8 @@ void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &region)
{
- QWindowSystemInterfacePrivate::ExposeEvent *e = new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalRegion(region, tlw));
+ QWindowSystemInterfacePrivate::ExposeEvent *e =
+ new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalExposedRegion(region, tlw));
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}