KWaylandServer

keystate_interface.cpp
1 /*
2  SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "keystate_interface.h"
8 #include "display.h"
9 
10 #include <QDebug>
11 #include <QVector>
12 #include <qwayland-server-keystate.h>
13 
14 namespace KWaylandServer
15 {
16 static const quint32 s_version = 1;
17 
18 class KeyStateInterfacePrivate : public QtWaylandServer::org_kde_kwin_keystate
19 {
20 public:
21  KeyStateInterfacePrivate(Display *d)
22  : QtWaylandServer::org_kde_kwin_keystate(*d, s_version)
23  {
24  }
25 
26  void org_kde_kwin_keystate_fetchStates(Resource *resource) override
27  {
28  for (int i = 0; i < m_keyStates.count(); ++i) {
29  send_stateChanged(resource->handle, i, m_keyStates[i]);
30  }
31  }
32 
33  QVector<KeyStateInterface::State> m_keyStates = QVector<KeyStateInterface::State>(3, KeyStateInterface::Unlocked);
34 };
35 
36 KeyStateInterface::KeyStateInterface(Display *d, QObject *parent)
37  : QObject(parent)
38  , d(new KeyStateInterfacePrivate(d))
39 {
40 }
41 
42 KeyStateInterface::~KeyStateInterface() = default;
43 
44 void KeyStateInterface::setState(KeyStateInterface::Key key, KeyStateInterface::State state)
45 {
46  d->m_keyStates[int(key)] = state;
47 
48  for (auto r : d->resourceMap()) {
49  d->send_stateChanged(r->handle, int(key), int(state));
50  }
51 }
52 
53 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.