diff --git a/input.cpp b/input.cpp --- a/input.cpp +++ b/input.cpp @@ -1868,6 +1868,8 @@ conn->setInputConfig(kwinApp()->inputConfig()); conn->updateLEDs(m_keyboard->xkb()->leds()); + waylandServer()->updateKeyState(m_keyboard->xkb()->leds()); + connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, waylandServer(), &WaylandServer::updateKeyState); connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, conn, &LibInput::Connection::updateLEDs); connect(conn, &LibInput::Connection::eventsRead, this, [this] { diff --git a/wayland_server.h b/wayland_server.h --- a/wayland_server.h +++ b/wayland_server.h @@ -21,6 +21,7 @@ #define KWIN_WAYLAND_SERVER_H #include +#include "keyboard_input.h" #include @@ -66,6 +67,7 @@ class XdgShellInterface; class XdgForeignInterface; class XdgOutputManagerInterface; +class KeyStateInterface; } } @@ -220,6 +222,7 @@ SocketPairConnection createConnection(); void simulateUserActivity(); + void updateKeyState(KWin::Xkb::LEDs leds); Q_SIGNALS: void shellClientAdded(KWin::ShellClient*); @@ -275,6 +278,7 @@ } m_internalConnection; KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr; + KWayland::Server::KeyStateInterface *m_keyState = nullptr; QList m_clients; QList m_internalClients; QHash m_clientIds; diff --git a/wayland_server.cpp b/wayland_server.cpp --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -65,7 +65,7 @@ #include #include #include - +#include // Qt #include @@ -375,6 +375,9 @@ m_XdgForeign = m_display->createXdgForeignInterface(m_display); m_XdgForeign->create(); + m_keyState = m_display->createKeyStateInterface(m_display); + m_keyState->create(); + return true; } @@ -756,4 +759,14 @@ } } +void WaylandServer::updateKeyState(KWin::Xkb::LEDs leds) +{ + if (!m_keyState) + return; + + m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::Xkb::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked); + m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::Xkb::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked); + m_keyState->setState(KeyStateInterface::Key::ScrollLock, leds & KWin::Xkb::LED::ScrollLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked); +} + }