diff options
author | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2023-02-20 15:26:45 +0200 |
---|---|---|
committer | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2023-02-28 14:09:40 +0200 |
commit | 59fae923d72eaf640035237ae6ddb1ccfeba2210 (patch) | |
tree | f8c2e6c865acb6059e4d292e8b2fe314ed3e37cf /src | |
parent | 82d4dad14fe763c6cb0b5d3c4ef4109243e8ab39 (diff) | |
download | qtwayland-59fae923d72eaf640035237ae6ddb1ccfeba2210.tar.gz |
Client: Update last input device on tablet tool tap
When user uses tablet exclusively to navigate in an app, the last
tracked input device will be null. As the result, any popup that
requires a popup grab will be backed by an xdg-toplevel rather than an
xdg-popup.
Fixes: QTBUG-111130
Change-Id: Ib87e732603bbe111c584361357727171825f8c68
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 1 | ||||
-rw-r--r-- | src/client/qwaylandtabletv2.cpp | 14 | ||||
-rw-r--r-- | src/client/qwaylandtabletv2_p.h | 6 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 17f01f49..115b39a8 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/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/client/qwaylandtabletv2.cpp b/src/client/qwaylandtabletv2.cpp index 5e1cc8fe..a7c3458f 100644 --- a/src/client/qwaylandtabletv2.cpp +++ b/src/client/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/client/qwaylandtabletv2_p.h b/src/client/qwaylandtabletv2_p.h index 7ddf02e6..3e0f4372 100644 --- a/src/client/qwaylandtabletv2_p.h +++ b/src/client/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<QWaylandTabletV2 *> m_tablets; QList<QWaylandTabletToolV2 *> m_tools; QList<QWaylandTabletPadV2 *> 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; |