Client: Properly handle tablet manager being announced after wl_seat

When wl_seat is announced we create QWaylandInputDevice and there check
whether the tablet manager is available, create the tablet seat,
and store it in mTabletSeat.

If zwp_tablet_manager_v2 is announced after wl_seat, which
happens e.g. on Weston, we created the tablet seat in the
QWaylandTabletManagerV2 ctor, but didn't update mTabletSeat.

To address this, we move the handling to QWaylandDisplay and pass the
manager to QWaylandInputDevice, similar to how we do it e.g. for
text-input.

Pick-to: 6.8 6.7
Change-Id: I902375ec0085d34ba99cbe59bbbc4051e7d1e802
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Nicolas Fella 2024-07-07 18:35:49 +02:00 committed by Shawn Rutledge
parent 4ad1c345a0
commit 5d77ed0258
4 changed files with 15 additions and 11 deletions

View File

@ -652,6 +652,9 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
#if QT_CONFIG(tabletevent)
} else if (interface == QLatin1String(QWaylandTabletManagerV2::interface()->name)) {
mGlobals.tabletManager.reset(new QWaylandTabletManagerV2(this, id, qMin(1, int(version))));
for (QWaylandInputDevice *inputDevice : std::as_const(mInputDevices))
inputDevice->setTabletSeat(
new QWaylandTabletSeatV2(mGlobals.tabletManager.get(), inputDevice));
#endif
} else if (interface == QLatin1String(QWaylandPointerGestures::interface()->name)) {
mGlobals.pointerGestures.reset(new QWaylandPointerGestures(this, id, 1));

View File

@ -563,6 +563,18 @@ void QWaylandInputDevice::setTextInput(QWaylandTextInputInterface *textInput)
mTextInput.reset(textInput);
}
#if QT_CONFIG(tabletevent)
void QWaylandInputDevice::setTabletSeat(QWaylandTabletSeatV2 *tabletSeat)
{
mTabletSeat.reset(tabletSeat);
}
QWaylandTabletSeatV2 *QWaylandInputDevice::tabletSeat() const
{
return mTabletSeat.get();
}
#endif
void QWaylandInputDevice::setTextInputMethod(QWaylandTextInputMethod *textInputMethod)
{
mTextInputMethod.reset(textInputMethod);

View File

@ -13,11 +13,6 @@ namespace QtWaylandClient {
QWaylandTabletManagerV2::QWaylandTabletManagerV2(QWaylandDisplay *display, uint id, uint version)
: zwp_tablet_manager_v2(display->wl_registry(), id, qMin(version, uint(1)))
{
// Create tabletSeats for all seats.
// This only works if we get the manager after all seats
const auto seats = display->inputDevices();
for (auto *seat : seats)
createTabletSeat(seat);
}
QWaylandTabletManagerV2::~QWaylandTabletManagerV2()
@ -25,11 +20,6 @@ QWaylandTabletManagerV2::~QWaylandTabletManagerV2()
destroy();
}
QWaylandTabletSeatV2 *QWaylandTabletManagerV2::createTabletSeat(QWaylandInputDevice *seat)
{
return new QWaylandTabletSeatV2(this, seat);
}
QWaylandTabletSeatV2::QWaylandTabletSeatV2(QWaylandTabletManagerV2 *manager, QWaylandInputDevice *seat)
: QtWayland::zwp_tablet_seat_v2(manager->get_tablet_seat(seat->wl_seat()))
, m_seat(seat)

View File

@ -43,7 +43,6 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandTabletManagerV2 : public QtWayland::zwp_tab
public:
explicit QWaylandTabletManagerV2(QWaylandDisplay *display, uint id, uint version);
~QWaylandTabletManagerV2() override;
QWaylandTabletSeatV2 *createTabletSeat(QWaylandInputDevice *seat);
};
class Q_WAYLANDCLIENT_EXPORT QWaylandTabletSeatV2 : public QObject, public QtWayland::zwp_tablet_seat_v2