Implement the keystate protocol

Summary: Depends on D20191

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20192
icc-effect-5.17.5
Aleix Pol 2019-06-21 16:02:50 +02:00
parent 994fafa912
commit bb9a5e57a1
3 changed files with 20 additions and 1 deletions

View File

@ -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] {

View File

@ -65,7 +65,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/xdgshell_interface.h>
#include <KWayland/Server/xdgforeign_interface.h>
#include <KWayland/Server/xdgoutput_interface.h>
#include <KWayland/Server/keystate_interface.h>
// Qt
#include <QDir>
@ -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);
}
}

View File

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_WAYLAND_SERVER_H
#include <kwinglobals.h>
#include "keyboard_input.h"
#include <QObject>
@ -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<ShellClient*> m_clients;
QList<ShellClient*> m_internalClients;
QHash<KWayland::Server::ClientConnection*, quint16> m_clientIds;