tablet: Fix disconnecting the tablet while the pen is still in proximity

libinput will send release and proximity out events after the device is
disconnected.
This just takes into account that tablet might be nullptr.

BUG: 442573
This commit is contained in:
Aleix Pol 2021-09-17 15:01:30 +02:00 committed by Aleix Pol Gonzalez
parent 7ffa7c48e5
commit 8825c01b15

View file

@ -1774,6 +1774,8 @@ public:
tool = createTool(event->tabletId()); tool = createTool(event->tabletId());
} }
// NOTE: tablet will be nullptr as the device is removed (see ::removeDevice) but events from the tool
// may still happen (e.g. Release or ProximityOut events)
auto tablet = static_cast<KWaylandServer::TabletV2Interface *>(event->tabletId().m_deviceGroupData); auto tablet = static_cast<KWaylandServer::TabletV2Interface *>(event->tabletId().m_deviceGroupData);
Toplevel *toplevel = input()->findToplevel(event->globalPos()); Toplevel *toplevel = input()->findToplevel(event->globalPos());
@ -1784,7 +1786,7 @@ public:
KWaylandServer::SurfaceInterface *surface = toplevel->surface(); KWaylandServer::SurfaceInterface *surface = toplevel->surface();
tool->setCurrentSurface(surface); tool->setCurrentSurface(surface);
if (!tool->isClientSupported() || !tablet->isSurfaceSupported(surface)) { if (!tool->isClientSupported() || (tablet && !tablet->isSurfaceSupported(surface))) {
return emulateTabletEvent(event); return emulateTabletEvent(event);
} }