xwayland: Guard against xwyayland connection closing in input spy

The event spy is removed when xwayland closed, but it's based on the
process not the wayland socket, so it can be temporarily out of sync.

There were no guards for the connection being null.

BUG: 471789
This commit is contained in:
David Edmundson 2023-06-30 09:19:18 +01:00
parent f09f5c608d
commit e93adbee07

View file

@ -157,8 +157,9 @@ public:
return;
}
auto client = surface->client();
if (waylandServer()->xWaylandConnection() != client) {
KWaylandServer::ClientConnection *client = surface->client();
KWaylandServer::ClientConnection *xwaylandClient = waylandServer()->xWaylandConnection();
if (xwaylandClient && xwaylandClient != client) {
KWaylandServer::KeyboardKeyState state{event->type() == QEvent::KeyPress};
if (!updateKey(event->nativeScanCode(), state)) {
return;
@ -170,7 +171,7 @@ public:
xkb->modifierState().locked,
xkb->currentLayout());
waylandServer()->seat()->keyboard()->sendKey(event->nativeScanCode(), state, waylandServer()->xWaylandConnection());
waylandServer()->seat()->keyboard()->sendKey(event->nativeScanCode(), state, xwaylandClient);
}
}