diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-10-27 12:52:54 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-03 20:36:35 +0100 |
commit | f6418343f1f8c08654f30191c1d8059761a016eb (patch) | |
tree | 9f11b822a806ded3ab9091d5d688c2dac0f0a33a /src/gui/kernel/qevent.cpp | |
parent | 46dd4df4b907a8cae1b6ef1fd5ba5a68e628d6fc (diff) |
Add QEventPoint::normalizedPosition() to replace normalizedPos()
In 4e400369c08db251cd489fec1229398c224d02b4 we deprecated
normalizedPos() because we suspect it's a legacy feature that few
users will need. However Qt developers keep bringing up the continued
usage in autotests over and over. (It's IMO not wrong to keep testing
deprecated functions in autotests, but the warning keeps attracting
attention.)
Of course it will turn out that normalizedPos() has users; we just
don't know how many. One way to look at it is: why should they copy
a snippet of code to calculate it, when it costs us so little to
continue to provide this accessor.
It might also turn out that some users will complain that in Qt 5
it was passed through from the device driver (or at least from the
window system API) to the application, and perhaps the replacement will
not always work, for example if availableVirtualGeometry() ends up
wrong, or there is some strange scenario that generates events that are
out-of-bounds for the device that the event professes to come from, so
that the "normalized" coordinates also go outside the [0..1] range.
We reserve the right to put back the storage in QEventPointPrivate if
the need arises; so that's why this function is not inline.
We continue to hope that startNormalizedPos() and lastNormalizedPos()
are used even less and won't be missed much, because it would be
wasteful to store them all the time if only a few users need them.
Change-Id: I23ed78843e3f9e16133c5b6f462884a3845f91b6
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7db77f5ee5..a4e44f5b8d 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -410,16 +410,21 @@ void QEventPoint::setAccepted(bool accepted) /*! \obsolete - Deprecated since Qt 6.0. Use globalPosition() instead. + \fn QPointF QPointerEvent::normalizedPos() const + Deprecated since Qt 6.0. Use normalizedPosition() instead. +*/ + +/*! Returns the normalized position of this point. - The coordinates are normalized to QInputDevice::availableVirtualGeometry(), - i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner. + The coordinates are calculated by transforming globalPosition() into the + space of QInputDevice::availableVirtualGeometry(), i.e. \c (0, 0) is the + top-left corner and \c (1, 1) is the bottom-right corner. - \sa startNormalizedPos(), lastNormalizedPos(), pos() + \sa globalPosition() */ -QPointF QEventPoint::normalizedPos() const +QPointF QEventPoint::normalizedPosition() const { auto geom = d->device->availableVirtualGeometry(); if (geom.isNull()) @@ -449,7 +454,7 @@ QPointF QEventPoint::startNormalizedPos() const move event. The coordinates are normalized to QInputDevice::availableVirtualGeometry(), - i.e. (0, 0) is the top-left corner and (1, 1) is the bottom-right corner. + i.e. \c (0, 0) is the top-left corner and \c (1, 1) is the bottom-right corner. \sa normalizedPos(), startNormalizedPos() */ |