diff --git a/src/xwayland/xwayland.cpp b/src/xwayland/xwayland.cpp index bb3bc45fd5..5f7250c407 100644 --- a/src/xwayland/xwayland.cpp +++ b/src/xwayland/xwayland.cpp @@ -375,26 +375,27 @@ public: auto keyboard = waylandServer()->seat()->keyboard(); auto surface = keyboard->focusedSurface(); - if (!surface) { + ClientConnection *xwaylandClient = waylandServer()->xWaylandConnection(); + + if (surface) { + ClientConnection *client = surface->client(); + if (xwaylandClient && xwaylandClient == client) { + return; + } + } + + KeyboardKeyState state{event->type() == QEvent::KeyPress}; + if (!updateKey(event->nativeScanCode(), state)) { return; } - ClientConnection *client = surface->client(); - ClientConnection *xwaylandClient = waylandServer()->xWaylandConnection(); - if (xwaylandClient && xwaylandClient != client) { - 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()); - auto xkb = input()->keyboard()->xkb(); - keyboard->sendModifiers(xkb->modifierState().depressed, - xkb->modifierState().latched, - xkb->modifierState().locked, - xkb->currentLayout()); - - keyboard->sendKey(event->nativeScanCode(), state, xwaylandClient); - } + 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)