diff --git a/input.cpp b/input.cpp index 253200795d..dd367266ba 100644 --- a/input.cpp +++ b/input.cpp @@ -1868,6 +1868,8 @@ void InputRedirection::setupLibInput() 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.cpp b/wayland_server.cpp index e62ad0e16d..c8082169d7 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -65,7 +65,7 @@ along with this program. If not, see . #include #include #include - +#include // Qt #include @@ -375,6 +375,9 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) 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::simulateUserActivity() } } +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); +} + } diff --git a/wayland_server.h b/wayland_server.h index b055e8ceba..09dd3657f0 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -21,6 +21,7 @@ along with this program. If not, see . #define KWIN_WAYLAND_SERVER_H #include +#include "keyboard_input.h" #include @@ -66,6 +67,7 @@ class XdgDecorationManagerInterface; class XdgShellInterface; class XdgForeignInterface; class XdgOutputManagerInterface; +class KeyStateInterface; } } @@ -220,6 +222,7 @@ public: SocketPairConnection createConnection(); void simulateUserActivity(); + void updateKeyState(KWin::Xkb::LEDs leds); Q_SIGNALS: void shellClientAdded(KWin::ShellClient*); @@ -275,6 +278,7 @@ private: } m_internalConnection; KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr; + KWayland::Server::KeyStateInterface *m_keyState = nullptr; QList m_clients; QList m_internalClients; QHash m_clientIds;