From 377385fa6ed9d34dde13383c842cd15b8cca6c97 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 13 Feb 2021 17:00:09 +0200 Subject: [PATCH] Send enter and modifiers events if wl_keyboard is bound by focused client We need to send out these events; otherwise the client may have incorrect state for the new wl_keyboard object. --- src/wayland/keyboard_interface.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wayland/keyboard_interface.cpp b/src/wayland/keyboard_interface.cpp index ad1d8e4261..48cb12a163 100644 --- a/src/wayland/keyboard_interface.cpp +++ b/src/wayland/keyboard_interface.cpp @@ -26,12 +26,25 @@ KeyboardInterfacePrivate::KeyboardInterfacePrivate(SeatInterface *s) void KeyboardInterfacePrivate::keyboard_bind_resource(Resource *resource) { + const ClientConnection *focusedClient = focusedSurface ? focusedSurface->client() : nullptr; + if (resource->version() >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) { send_repeat_info(resource->handle, keyRepeat.charactersPerSecond, keyRepeat.delay); } if (!keymap.isNull()) { send_keymap(resource->handle, keymap_format::keymap_format_xkb_v1, keymap->handle(), keymap->size()); } + + if (focusedClient && focusedClient->client() == resource->client()) { + const QVector keys = pressedKeys(); + const QByteArray keysData = QByteArray::fromRawData(reinterpret_cast(keys.data()), + sizeof(quint32) * keys.count()); + const quint32 serial = seat->display()->nextSerial(); + + send_enter(resource->handle, serial, focusedSurface->resource(), keysData); + send_modifiers(resource->handle, serial, modifiers.depressed, modifiers.latched, + modifiers.locked, modifiers.group); + } } QList KeyboardInterfacePrivate::keyboardsForClient(ClientConnection *client) const