diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h index 17f01f4904a..115b39a8896 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h @@ -84,6 +84,7 @@ public: uint32_t capabilities() const { return mCaps; } + QWaylandDisplay *display() const { return mQDisplay; } struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); } #if QT_CONFIG(cursor) diff --git a/src/plugins/platforms/wayland/qwaylandtabletv2.cpp b/src/plugins/platforms/wayland/qwaylandtabletv2.cpp index 5e1cc8fe482..a7c3458f71d 100644 --- a/src/plugins/platforms/wayland/qwaylandtabletv2.cpp +++ b/src/plugins/platforms/wayland/qwaylandtabletv2.cpp @@ -27,6 +27,7 @@ QWaylandTabletSeatV2 *QWaylandTabletManagerV2::createTabletSeat(QWaylandInputDev QWaylandTabletSeatV2::QWaylandTabletSeatV2(QWaylandTabletManagerV2 *manager, QWaylandInputDevice *seat) : QtWayland::zwp_tablet_seat_v2(manager->get_tablet_seat(seat->wl_seat())) + , m_seat(seat) { } @@ -53,7 +54,7 @@ void QWaylandTabletSeatV2::zwp_tablet_seat_v2_tablet_added(zwp_tablet_v2 *id) void QWaylandTabletSeatV2::zwp_tablet_seat_v2_tool_added(zwp_tablet_tool_v2 *id) { - auto *tool = new QWaylandTabletToolV2(id); + auto *tool = new QWaylandTabletToolV2(this, id); m_tools.push_back(tool); connect(tool, &QWaylandTabletToolV2::destroyed, this, [this, tool] { m_tools.removeOne(tool); }); } @@ -76,8 +77,9 @@ void QWaylandTabletV2::zwp_tablet_v2_removed() delete this; } -QWaylandTabletToolV2::QWaylandTabletToolV2(::zwp_tablet_tool_v2 *tool) +QWaylandTabletToolV2::QWaylandTabletToolV2(QWaylandTabletSeatV2 *tabletSeat, ::zwp_tablet_tool_v2 *tool) : QtWayland::zwp_tablet_tool_v2(tool) + , m_tabletSeat(tabletSeat) { } @@ -163,8 +165,14 @@ void QWaylandTabletToolV2::zwp_tablet_tool_v2_proximity_out() void QWaylandTabletToolV2::zwp_tablet_tool_v2_down(uint32_t serial) { - Q_UNUSED(serial); m_pending.down = true; + + if (m_pending.proximitySurface) { + if (QWaylandWindow *window = m_pending.proximitySurface->waylandWindow()) { + QWaylandInputDevice *seat = m_tabletSeat->seat(); + seat->display()->setLastInputDevice(seat, serial, window); + } + } } void QWaylandTabletToolV2::zwp_tablet_tool_v2_up() diff --git a/src/plugins/platforms/wayland/qwaylandtabletv2_p.h b/src/plugins/platforms/wayland/qwaylandtabletv2_p.h index 7ddf02e6748..3e0f4372b96 100644 --- a/src/plugins/platforms/wayland/qwaylandtabletv2_p.h +++ b/src/plugins/platforms/wayland/qwaylandtabletv2_p.h @@ -52,12 +52,15 @@ public: explicit QWaylandTabletSeatV2(QWaylandTabletManagerV2 *manager, QWaylandInputDevice *seat); ~QWaylandTabletSeatV2() override; + QWaylandInputDevice *seat() const { return m_seat; } + protected: void zwp_tablet_seat_v2_tablet_added(struct ::zwp_tablet_v2 *id) override; void zwp_tablet_seat_v2_tool_added(struct ::zwp_tablet_tool_v2 *id) override; void zwp_tablet_seat_v2_pad_added(struct ::zwp_tablet_pad_v2 *id) override; private: + QWaylandInputDevice *m_seat; QList m_tablets; QList m_tools; QList m_pads; @@ -81,7 +84,7 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandTabletToolV2 : public QObject, public QtWay { Q_OBJECT public: - explicit QWaylandTabletToolV2(::zwp_tablet_tool_v2 *tool); + QWaylandTabletToolV2(QWaylandTabletSeatV2 *tabletSeat, ::zwp_tablet_tool_v2 *tool); protected: void zwp_tablet_tool_v2_type(uint32_t tool_type) override; @@ -105,6 +108,7 @@ protected: void zwp_tablet_tool_v2_frame(uint32_t time) override; private: + QWaylandTabletSeatV2 *m_tabletSeat; // Static state (sent before done event) QPointingDevice::PointerType m_pointerType = QPointingDevice::PointerType::Unknown;