diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-10-21 12:02:15 +0200 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2020-01-03 23:47:02 +0100 |
commit | eaf72c8ffdcdc6e9a3e1e3d67bf09db1dabe7af6 (patch) | |
tree | 705871987df521c50de0442273c0cacfd0d24a7e /src | |
parent | 919efcd994b5284bb73e11859ca953e9186b0bae (diff) |
Client: Don't use deprecated handleMouseEvent version
The new version requires the button that caused the event, as well as the event
type. Instead of adding a conversion functions to and from
QWaylandInputDevice::Type to QEvent::Type, just use QEvent::Type directly, as
there is one-to-one mappings for all the event types we need.
Fixes: QTBUG-80044
Change-Id: I0f6e0e8e7f2e026a1d601f86e819affe0570a1b2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 38 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 21 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 32 |
3 files changed, 46 insertions, 45 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 8f23805de..56809f77f 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -630,8 +630,8 @@ class EnterEvent : public QWaylandPointerEvent { public: EnterEvent(QWaylandWindow *surface, const QPointF &local, const QPointF &global) - : QWaylandPointerEvent(QWaylandPointerEvent::Enter, Qt::NoScrollPhase, surface, 0, - local, global, nullptr, Qt::NoModifier) + : QWaylandPointerEvent(QEvent::Enter, Qt::NoScrollPhase, surface, 0, + local, global, Qt::NoButton, Qt::NoButton, Qt::NoModifier) {} }; @@ -675,8 +675,8 @@ class LeaveEvent : public QWaylandPointerEvent { public: LeaveEvent(QWaylandWindow *surface, const QPointF &localPos, const QPointF &globalPos) - : QWaylandPointerEvent(QWaylandPointerEvent::Leave, Qt::NoScrollPhase, surface, 0, - localPos, globalPos, nullptr, Qt::NoModifier) + : QWaylandPointerEvent(QEvent::Leave, Qt::NoScrollPhase, surface, 0, + localPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier) {} }; @@ -705,8 +705,8 @@ class MotionEvent : public QWaylandPointerEvent public: MotionEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Motion, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + : QWaylandPointerEvent(QEvent::MouseMove, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, Qt::NoButton, modifiers) { } }; @@ -744,9 +744,10 @@ class PressEvent : public QWaylandPointerEvent { public: PressEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, - const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Press, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) + : QWaylandPointerEvent(QEvent::MouseButtonPress, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, button, modifiers) { } }; @@ -755,9 +756,10 @@ class ReleaseEvent : public QWaylandPointerEvent { public: ReleaseEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, - const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Release, Qt::NoScrollPhase, surface, - timestamp, localPos, globalPos, buttons, modifiers) + const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) + : QWaylandPointerEvent(QEvent::MouseButtonRelease, Qt::NoScrollPhase, surface, + timestamp, localPos, globalPos, buttons, button, modifiers) { } }; @@ -818,9 +820,9 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time } if (state) - setFrameEvent(new PressEvent(window, time, pos, global, mButtons, mParent->modifiers())); + setFrameEvent(new PressEvent(window, time, pos, global, mButtons, qt_button, mParent->modifiers())); else - setFrameEvent(new ReleaseEvent(window, time, pos, global, mButtons, mParent->modifiers())); + setFrameEvent(new ReleaseEvent(window, time, pos, global, mButtons, qt_button, mParent->modifiers())); } void QWaylandInputDevice::Pointer::invalidateFocus() @@ -848,7 +850,7 @@ public: WheelEvent(QWaylandWindow *surface, Qt::ScrollPhase phase, ulong timestamp, const QPointF &local, const QPointF &global, const QPoint &pixelDelta, const QPoint &angleDelta, Qt::MouseEventSource source, Qt::KeyboardModifiers modifiers) - : QWaylandPointerEvent(QWaylandPointerEvent::Wheel, phase, surface, timestamp, + : QWaylandPointerEvent(QEvent::Wheel, phase, surface, timestamp, local, global, pixelDelta, angleDelta, source, modifiers) { } @@ -1084,11 +1086,13 @@ void QWaylandInputDevice::Pointer::flushFrameEvent() if (auto *event = mFrameData.event) { if (auto window = event->surface) { window->handleMouse(mParent, *event); - } else if (mFrameData.event->type == QWaylandPointerEvent::Type::Release) { + } else if (mFrameData.event->type == QEvent::MouseButtonRelease) { // If the window has been destroyed, we still need to report an up event, but it can't // be handled by the destroyed window (obviously), so send the event here instead. QWindowSystemInterface::handleMouseEvent(nullptr, event->timestamp, event->local, - event->global, event->buttons, event->modifiers); + event->global, event->buttons, + event->button, event->type, + event->modifiers);// , Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); } delete mFrameData.event; mFrameData.event = nullptr; diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index a567c57b4..87f8559c4 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -401,29 +401,21 @@ class QWaylandPointerEvent { Q_GADGET public: - enum Type { - Enter, - Leave, - Motion, - Press, - Release, - Wheel - }; - Q_ENUM(Type) - - inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, + inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, - Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) + Qt::MouseButtons buttons, Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) : type(type) , phase(phase) , timestamp(timestamp) , local(localPos) , global(globalPos) , buttons(buttons) + , button(button) , modifiers(modifiers) , surface(surface) {} - inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, + inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface, ulong timestamp, const QPointF &local, const QPointF &global, const QPoint &pixelDelta, const QPoint &angleDelta, Qt::MouseEventSource source, @@ -440,12 +432,13 @@ public: , surface(surface) {} - Type type; + QEvent::Type type = QEvent::None; Qt::ScrollPhase phase = Qt::NoScrollPhase; ulong timestamp = 0; QPointF local; QPointF global; Qt::MouseButtons buttons; + Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button) Qt::KeyboardModifiers modifiers; QPoint pixelDelta; QPoint angleDelta; diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 0a623e9a2..8cc26d71c 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -869,7 +869,7 @@ QWaylandWindow *QWaylandWindow::transientParent() const void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e) { - if (e.type == QWaylandPointerEvent::Leave) { + if (e.type == QEvent::Leave) { if (mWindowDecoration) { if (mMouseEventsInContentArea) QWindowSystemInterface::handleLeaveEvent(window()); @@ -886,24 +886,26 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan handleMouseEventWithDecoration(inputDevice, e); } else { switch (e.type) { - case QWaylandPointerEvent::Enter: + case QEvent::Enter: QWindowSystemInterface::handleEnterEvent(window(), e.local, e.global); break; - case QWaylandPointerEvent::Press: - case QWaylandPointerEvent::Release: - case QWaylandPointerEvent::Motion: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.modifiers); + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.button, e.type, e.modifiers); break; - case QWaylandPointerEvent::Wheel: + case QEvent::Wheel: QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, false); break; + default: + Q_UNREACHABLE(); } } #if QT_CONFIG(cursor) - if (e.type == QWaylandPointerEvent::Enter) { + if (e.type == QEvent::Enter) { QRect contentGeometry = windowContentGeometry().marginsRemoved(frameMargins()); if (contentGeometry.contains(e.local.toPoint())) restoreMouseCursor(inputDevice); @@ -947,21 +949,23 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe } switch (e.type) { - case QWaylandPointerEvent::Enter: + case QEvent::Enter: QWindowSystemInterface::handleEnterEvent(window(), localTranslated, globalTranslated); break; - case QWaylandPointerEvent::Press: - case QWaylandPointerEvent::Release: - case QWaylandPointerEvent::Motion: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers); + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.button, e.type, e.modifiers); break; - case QWaylandPointerEvent::Wheel: { + case QEvent::Wheel: { QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, false); break; } + default: + Q_UNREACHABLE(); } mMouseEventsInContentArea = true; |