KWin
Loading...
Searching...
No Matches
keystate.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "keystate.h"
8#include "display.h"
9
10#include "keyboard_input.h"
11#include "xkb.h"
12
13#include <QDebug>
14#include <QList>
15#include <qwayland-server-keystate.h>
16
17namespace KWin
18{
19
20static const quint32 s_version = 1;
21
22class KeyStateInterfacePrivate : public QtWaylandServer::org_kde_kwin_keystate
23{
24public:
26 : QtWaylandServer::org_kde_kwin_keystate(*d, s_version)
27 {
28 }
29
30 void org_kde_kwin_keystate_fetchStates(Resource *resource) override
31 {
32 const LEDs leds = input()->keyboard()->xkb()->leds();
33
34 send_stateChanged(resource->handle, key_capslock, leds & LED::CapsLock ? state_locked : state_unlocked);
35 send_stateChanged(resource->handle, key_numlock, leds & LED::NumLock ? state_locked : state_unlocked);
36 send_stateChanged(resource->handle, key_scrolllock, leds & LED::ScrollLock ? state_locked : state_unlocked);
37 }
38};
39
41 : QObject(parent)
42 , d(new KeyStateInterfacePrivate(display))
43{
44 connect(input()->keyboard(), &KeyboardInputRedirection::ledsChanged, this, [this]() {
45 const auto resources = d->resourceMap();
46 for (const auto &resource : resources) {
47 d->org_kde_kwin_keystate_fetchStates(resource);
48 }
49 });
50}
51
53
54}
55
56#include "moc_keystate.cpp"
Class holding the Wayland server display loop.
Definition display.h:34
KeyboardInputRedirection * keyboard() const
Definition input.h:216
~KeyStateInterface() override
KeyStateInterface(Display *display, QObject *parent=nullptr)
Definition keystate.cpp:40
void org_kde_kwin_keystate_fetchStates(Resource *resource) override
Definition keystate.cpp:30
LEDs leds() const
Definition xkb.h:70
InputRedirection * input()
Definition input.h:549