Changeset View
Changeset View
Standalone View
Standalone View
src/client/keystate.cpp
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2014 Martin Gräßlin <mgraesslin@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | #include "keystate.h" | ||||
21 | #include "wayland_pointer_p.h" | ||||
22 | #include <QPointer> | ||||
23 | #include <QDebug> | ||||
24 | #include <wayland-client-protocol.h> | ||||
25 | #include <wayland-keystate-client-protocol.h> | ||||
26 | | ||||
27 | namespace KWayland | ||||
28 | { | ||||
29 | namespace Client | ||||
30 | { | ||||
31 | | ||||
32 | class Q_DECL_HIDDEN Keystate::Private | ||||
33 | { | ||||
34 | public: | ||||
35 | Private() {} | ||||
36 | | ||||
37 | WaylandPointer<org_kde_kwin_keystate, org_kde_kwin_keystate_destroy> keystate; | ||||
38 | | ||||
39 | static void org_kde_kwin_keystate_stateChanged(void *data, struct org_kde_kwin_keystate */*keystate*/, uint32_t k, uint32_t s) { | ||||
40 | auto q = static_cast<Keystate*>(data); | ||||
41 | q->stateChanged(Key(k), State(s)); | ||||
42 | } | ||||
43 | | ||||
44 | static const org_kde_kwin_keystate_listener s_listener; | ||||
45 | }; | ||||
46 | | ||||
47 | const org_kde_kwin_keystate_listener Keystate::Private::s_listener = { | ||||
48 | org_kde_kwin_keystate_stateChanged | ||||
49 | }; | ||||
50 | | ||||
51 | Keystate::Keystate(QObject *parent) | ||||
52 | : QObject(parent) | ||||
53 | , d(new Private()) | ||||
54 | { | ||||
55 | } | ||||
56 | | ||||
57 | Keystate::~Keystate() = default; | ||||
58 | | ||||
59 | void Keystate::fetchStates() | ||||
60 | { | ||||
61 | org_kde_kwin_keystate_fetchStates(d->keystate); | ||||
62 | } | ||||
63 | | ||||
64 | void Keystate::setup(org_kde_kwin_keystate* keystate) | ||||
65 | { | ||||
66 | d->keystate.setup(keystate); | ||||
67 | org_kde_kwin_keystate_add_listener(keystate, &Keystate::Private::s_listener, this); | ||||
68 | } | ||||
69 | | ||||
70 | void Keystate::destroy() | ||||
71 | { | ||||
72 | d->keystate.destroy(); | ||||
73 | } | ||||
74 | | ||||
75 | void Keystate::setEventQueue(KWayland::Client::EventQueue* /*queue*/) | ||||
76 | { | ||||
77 | } | ||||
78 | | ||||
79 | | ||||
80 | } | ||||
81 | } |