summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-19 21:54:52 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-19 21:54:53 +0200
commit15dc8b1d8e2db00dfcbe8d7f21150658f5de45b6 (patch)
tree6b9c908ca1cf0b1395fa91415f19b5adf8642ca7 /src/gui
parentecc83677006dc7dffcd2417b1e3cff88b0615756 (diff)
parent6234286925153279ca259cec04429fa584187b16 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qevent.cpp24
-rw-r--r--src/gui/kernel/qevent.h1
-rw-r--r--src/gui/kernel/qevent_p.h4
-rw-r--r--src/gui/kernel/qguiapplication.cpp2
-rw-r--r--src/gui/rhi/qshaderdescription.cpp2
-rw-r--r--src/gui/text/qtextdocument.cpp26
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp12
7 files changed, 53 insertions, 18 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 616cca1422..d41e3e5e3c 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -931,6 +931,30 @@ QWheelEvent::~QWheelEvent()
\endlist
*/
+/*!
+ \fn QPoint QWheelEvent::position() const
+
+ Returns the position of the mouse cursor relative to the widget
+ that received the event.
+
+ If you move your widgets around in response to mouse events,
+ use globalPosition() instead of this function.
+
+ \sa globalPosition()
+*/
+
+/*!
+ \fn QPoint QWheelEvent::globalPosition() const
+
+ Returns the global position of the mouse pointer \e{at the time
+ of the event}. This is important on asynchronous window systems
+ such as X11; whenever you move your widgets around in response to
+ mouse events, globalPosition() can differ a lot from the current
+ cursor position returned by QCursor::pos().
+
+ \sa position()
+*/
+
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\fn int QWheelEvent::delta() const
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index b73d90529a..bf00d4a9a3 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -959,6 +959,7 @@ public:
friend class QGuiApplicationPrivate;
friend class QApplication;
friend class QApplicationPrivate;
+ friend class QQuickPointerTouchEvent;
};
#if QT_DEPRECATED_SINCE(5, 0)
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index c2d8bd72b9..b7645496f8 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -67,7 +67,8 @@ public:
state(Qt::TouchPointReleased),
pressure(-1),
rotation(0),
- ellipseDiameters(0, 0)
+ ellipseDiameters(0, 0),
+ stationaryWithModifiedProperty(false)
{ }
inline QTouchEventTouchPointPrivate *detach()
@@ -91,6 +92,7 @@ public:
QSizeF ellipseDiameters;
QVector2D velocity;
QTouchEvent::TouchPoint::InfoFlags flags;
+ bool stationaryWithModifiedProperty : 1;
QVector<QPointF> rawScreenPositions;
};
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index c21bc90d39..c5d8cf9bf9 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2845,10 +2845,12 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (touchPoint.state() == Qt::TouchPointStationary) {
if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
touchInfo.touchPoint.setVelocity(touchPoint.velocity());
+ touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
if (!qFuzzyCompare(touchInfo.touchPoint.pressure(), touchPoint.pressure())) {
touchInfo.touchPoint.setPressure(touchPoint.pressure());
+ touchPoint.d->stationaryWithModifiedProperty = true;
stationaryTouchPointChangedProperty = true;
}
} else {
diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp
index c38a83c497..179d5f3a07 100644
--- a/src/gui/rhi/qshaderdescription.cpp
+++ b/src/gui/rhi/qshaderdescription.cpp
@@ -1022,7 +1022,7 @@ void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc)
return;
}
- Q_ASSERT(ref.load() == 1); // must be detached
+ Q_ASSERT(ref.loadRelaxed() == 1); // must be detached
inVars.clear();
outVars.clear();
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 3652a180a8..22c249d604 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1970,9 +1970,12 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
QRectF body = QRectF(QPointF(0, 0), d->pageSize);
QPointF pageNumberPos;
+ qreal sourceDpiX = qt_defaultDpiX();
+ qreal sourceDpiY = qt_defaultDpiY();
+ const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
+ const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
+
if (documentPaginated) {
- qreal sourceDpiX = qt_defaultDpi();
- qreal sourceDpiY = sourceDpiX;
QPaintDevice *dev = doc->documentLayout()->paintDevice();
if (dev) {
@@ -1980,9 +1983,6 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
sourceDpiY = dev->logicalDpiY();
}
- const qreal dpiScaleX = qreal(printer->logicalDpiX()) / sourceDpiX;
- const qreal dpiScaleY = qreal(printer->logicalDpiY()) / sourceDpiY;
-
// scale to dpi
p.scale(dpiScaleX, dpiScaleY);
@@ -2011,15 +2011,21 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
// copy the custom object handlers
layout->d_func()->handlers = documentLayout()->d_func()->handlers;
- int dpiy = p.device()->logicalDpiY();
- int margin = (int) ((2/2.54)*dpiy); // 2 cm margins
+ // 2 cm margins, scaled to device in QTextDocumentLayoutPrivate::layoutFrame
+ const int horizontalMargin = int((2/2.54)*sourceDpiX);
+ const int verticalMargin = int((2/2.54)*sourceDpiY);
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
- fmt.setMargin(margin);
+ fmt.setLeftMargin(horizontalMargin);
+ fmt.setRightMargin(horizontalMargin);
+ fmt.setTopMargin(verticalMargin);
+ fmt.setBottomMargin(verticalMargin);
doc->rootFrame()->setFrameFormat(fmt);
+ // pageNumberPos must be in device coordinates, so scale to device here
+ const int dpiy = p.device()->logicalDpiY();
body = QRectF(0, 0, printer->width(), printer->height());
- pageNumberPos = QPointF(body.width() - margin,
- body.height() - margin
+ pageNumberPos = QPointF(body.width() - horizontalMargin * dpiScaleX,
+ body.height() - verticalMargin * dpiScaleY
+ QFontMetrics(doc->defaultFont(), p.device()).ascent()
+ 5 * dpiy / 72.0);
clonedDoc->setPageSize(body.size());
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index b02723c047..a9a177da8b 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2915,24 +2915,24 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in
{
QTextFrameFormat fformat = f->frameFormat();
// set sizes of this frame from the format
- QFixed tm = QFixed::fromReal(fformat.topMargin());
+ QFixed tm = QFixed::fromReal(scaleToDevice(fformat.topMargin())).round();
if (tm != fd->topMargin) {
fd->topMargin = tm;
fullLayout = true;
}
- QFixed bm = QFixed::fromReal(fformat.bottomMargin());
+ QFixed bm = QFixed::fromReal(scaleToDevice(fformat.bottomMargin())).round();
if (bm != fd->bottomMargin) {
fd->bottomMargin = bm;
fullLayout = true;
}
- fd->leftMargin = QFixed::fromReal(fformat.leftMargin());
- fd->rightMargin = QFixed::fromReal(fformat.rightMargin());
- QFixed b = QFixed::fromReal(fformat.border());
+ fd->leftMargin = QFixed::fromReal(scaleToDevice(fformat.leftMargin())).round();
+ fd->rightMargin = QFixed::fromReal(scaleToDevice(fformat.rightMargin())).round();
+ QFixed b = QFixed::fromReal(scaleToDevice(fformat.border())).round();
if (b != fd->border) {
fd->border = b;
fullLayout = true;
}
- QFixed p = QFixed::fromReal(fformat.padding());
+ QFixed p = QFixed::fromReal(scaleToDevice(fformat.padding())).round();
if (p != fd->padding) {
fd->padding = p;
fullLayout = true;