QtGui: Use single precision for mouseMove detection
QGuiApplication::lastCursorPosition is a QPointF, and (at least on macOS) compares always different from the QPointF stored in the event. This might be due to the translation from system coordinates to QPointF introducing noise. The result is that even a simple button press causes mouseMove events to be delivered. To prevent this event noise, overload equality operators for the special QLastCursorPosition type when comparing with QPointF to explicitly use single precision comparison. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111170 Change-Id: I82ea23ac9f4fa80c55c9c5c742527dd7ee74fd99 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
742e79312f
commit
eedcda282f
@ -207,6 +207,28 @@ public:
|
||||
|
||||
constexpr void reset() noexcept { *this = QLastCursorPosition{}; }
|
||||
|
||||
// QGuiApplicationPrivate::lastCursorPosition is used for mouse-move detection
|
||||
// but even QPointF's qFuzzCompare on doubles is too precise, and causes move-noise
|
||||
// e.g. on macOS (see QTBUG-111170). So we specialize the equality operators here
|
||||
// to use single-point precision.
|
||||
friend constexpr bool operator==(const QLastCursorPosition &p1, const QPointF &p2) noexcept
|
||||
{
|
||||
return qFuzzyCompare(float(p1.x()), float(p2.x()))
|
||||
&& qFuzzyCompare(float(p1.y()), float(p2.y()));
|
||||
}
|
||||
friend constexpr bool operator!=(const QLastCursorPosition &p1, const QPointF &p2) noexcept
|
||||
{
|
||||
return !(p1 == p2);
|
||||
}
|
||||
friend constexpr bool operator==(const QPointF &p1, const QLastCursorPosition &p2) noexcept
|
||||
{
|
||||
return p2 == p1;
|
||||
}
|
||||
friend constexpr bool operator!=(const QPointF &p1, const QLastCursorPosition &p2) noexcept
|
||||
{
|
||||
return !(p2 == p1);
|
||||
}
|
||||
|
||||
private:
|
||||
QPointF thePoint;
|
||||
} lastCursorPosition;
|
||||
|
Loading…
Reference in New Issue
Block a user