diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-08-03 13:01:49 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-08-06 12:53:37 +0200 |
commit | a95d4f68ee9ecf832f34cecaf11f8088cdc935f6 (patch) | |
tree | cf5294b6a03ca86e61eea099ea91527259cfab8d /src/gui/kernel/qevent.cpp | |
parent | 6d9ec41f6fef7af0129d13fc99fffc7a548f6125 (diff) |
Add qt.pointer.grab logging in QEventPoint
Add the logging category qt.pointer.grab, which generalizes the
qt.quick.pointer.grab category in Qt 5 (and is almost always needed
for troubleshooting Qt Quick pointer-handling bugs).
Change-Id: I10b4f43aa60e8717d92ac43384d8fdeefd41d836
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ea831f9a40..aaf6da85cd 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -50,6 +50,7 @@ #include "qmimedata.h" #include "qevent_p.h" #include "qmath.h" +#include "qloggingcategory.h" #if QT_CONFIG(draganddrop) #include <qpa/qplatformdrag.h> @@ -60,6 +61,18 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcPointerGrab, "qt.pointer.grab") + +static const QString pointDeviceName(const QEventPoint *point) +{ + if (!point->event()) + return {}; + auto device = point->event()->device(); + QString deviceName = (device ? device->name() : QLatin1String("null device")); + deviceName.resize(16, u' '); // shorten, and align in case of sequential output + return deviceName; +} + /*! \class QEnterEvent \ingroup events @@ -262,6 +275,12 @@ void QEventPoint::setAccepted(bool accepted) */ void QEventPoint::setExclusiveGrabber(QObject *exclusiveGrabber) { + if (m_exclusiveGrabber == exclusiveGrabber) + return; + if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) { + qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << Qt::hex << m_pointId << m_state << "@" << m_scenePos + << ": grab" << m_exclusiveGrabber << "->" << exclusiveGrabber; + } m_exclusiveGrabber = exclusiveGrabber; m_globalGrabPos = m_globalPos; } @@ -276,10 +295,18 @@ void QEventPoint::setExclusiveGrabber(QObject *exclusiveGrabber) void QEventPoint::setPassiveGrabbers(const QList<QPointer<QObject> > &grabbers) { m_passiveGrabbers = grabbers; + if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) { + qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << Qt::hex << m_pointId << m_state + << ": grab (passive)" << grabbers; + } } void QEventPoint::clearPassiveGrabbers() { + if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) { + qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << Qt::hex << m_pointId << m_state + << ": clearing" << m_passiveGrabbers; + } m_passiveGrabbers.clear(); } |