xwayland: Send to xwayland even when no window is focussed

In the codepath to keep xwayland notified of key presses we have to
check the focussed window is not already an xwayland client. To avoid a
null dereference a guard is added that the focussed window is not null,
however the current code incorrectly returns early intead of skipping
just the relevant check.

BUG: 478705
wilder/Plasma/6.2
David Edmundson 2 years ago
parent 53a61dfac0
commit 2025bf4c6b
  1. 47
      src/xwayland/xwayland.cpp

@ -375,26 +375,27 @@ public:
auto keyboard = waylandServer()->seat()->keyboard();
auto surface = keyboard->focusedSurface();
if (!surface) {
return;
}
ClientConnection *client = surface->client();
ClientConnection *xwaylandClient = waylandServer()->xWaylandConnection();
if (xwaylandClient && xwaylandClient != client) {
KeyboardKeyState state{event->type() == QEvent::KeyPress};
if (!updateKey(event->nativeScanCode(), state)) {
if (surface) {
ClientConnection *client = surface->client();
if (xwaylandClient && xwaylandClient == client) {
return;
}
}
auto xkb = input()->keyboard()->xkb();
keyboard->sendModifiers(xkb->modifierState().depressed,
xkb->modifierState().latched,
xkb->modifierState().locked,
xkb->currentLayout());
keyboard->sendKey(event->nativeScanCode(), state, xwaylandClient);
KeyboardKeyState state{event->type() == QEvent::KeyPress};
if (!updateKey(event->nativeScanCode(), state)) {
return;
}
auto xkb = input()->keyboard()->xkb();
keyboard->sendModifiers(xkb->modifierState().depressed,
xkb->modifierState().latched,
xkb->modifierState().locked,
xkb->currentLayout());
keyboard->sendKey(event->nativeScanCode(), state, xwaylandClient);
}
void pointerEvent(KWin::MouseEvent *event) override
@ -406,17 +407,17 @@ public:
auto pointer = waylandServer()->seat()->pointer();
auto surface = pointer->focusedSurface();
if (!surface) {
return;
}
ClientConnection *client = surface->client();
ClientConnection *xwaylandClient = waylandServer()->xWaylandConnection();
if (xwaylandClient && xwaylandClient != client) {
PointerButtonState state{event->type() == QEvent::MouseButtonPress};
pointer->sendButton(event->nativeButton(), state, xwaylandClient);
if (surface) {
ClientConnection *client = surface->client();
if (xwaylandClient && xwaylandClient == client) {
return;
}
}
PointerButtonState state{event->type() == QEvent::MouseButtonPress};
pointer->sendButton(event->nativeButton(), state, xwaylandClient);
}
bool updateKey(quint32 key, KeyboardKeyState state)

Loading…
Cancel
Save