Line |
Branch |
Exec |
Source |
1 |
|
|
/******************************************************************** |
2 |
|
|
Copyright 2020 Adrien Faveraux <ad1rie3@hotmail.fr> |
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_p.h" |
21 |
|
|
|
22 |
|
|
namespace Wrapland::Server |
23 |
|
|
{ |
24 |
|
|
|
25 |
|
|
const struct org_kde_kwin_keystate_interface KeyState::Private::s_interface |
26 |
|
|
= {KeyState::Private::cb<fetchStatesCallback>}; |
27 |
|
|
|
28 |
|
✗ |
KeyState::Private::Private(Display* display, KeyState* q_ptr) |
29 |
|
✗ |
: Wayland::Global<KeyState>(q_ptr, display, &org_kde_kwin_keystate_interface, &s_interface) |
30 |
|
|
{ |
31 |
|
✗ |
create(); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
✗ |
void KeyState::Private::fetchStatesCallback(KeyStateBind* bind) |
35 |
|
|
{ |
36 |
|
✗ |
auto priv = bind->global()->handle->d_ptr.get(); |
37 |
|
|
|
38 |
|
✗ |
auto index{0}; |
39 |
|
✗ |
for (auto&& state : priv->key_states) { |
40 |
|
✗ |
priv->send<org_kde_kwin_keystate_send_stateChanged>(bind, index, state); |
41 |
|
✗ |
index++; |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
✗ |
KeyState::KeyState(Display* display) |
46 |
|
✗ |
: d_ptr(new Private(display, this)) |
47 |
|
|
{ |
48 |
|
|
} |
49 |
|
✗ |
KeyState::~KeyState() = default; |
50 |
|
|
|
51 |
|
✗ |
void KeyState::setState(KeyState::Key key, KeyState::State state) |
52 |
|
|
{ |
53 |
|
✗ |
d_ptr->key_states.at(static_cast<size_t>(key)) = state; |
54 |
|
✗ |
d_ptr->send<org_kde_kwin_keystate_send_stateChanged>(static_cast<int>(key), |
55 |
|
✗ |
static_cast<int>(state)); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
} |
59 |
|
|
|