Changeset View
Changeset View
Standalone View
Standalone View
xkb.h
- This file was copied from keyboard_input.h.
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2013, 2016 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright (C) 2013, 2016, 2017 Martin Gräßlin <mgraesslin@kde.org> | ||
6 | 6 | | |||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 10 | (at your option) any later version. | ||
11 | 11 | | |||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_KEYBOARD_INPUT_H | 20 | #ifndef KWIN_XKB_H | ||
21 | #define KWIN_KEYBOARD_INPUT_H | 21 | #define KWIN_XKB_H | ||
22 | | ||||
23 | #include "input.h" | 22 | #include "input.h" | ||
24 | 23 | | |||
25 | #include <QObject> | 24 | #include <kwin_export.h> | ||
26 | #include <QPointer> | 25 | | ||
27 | #include <QPointF> | 26 | #include <KSharedConfig> | ||
28 | 27 | | |||
29 | #include <QLoggingCategory> | 28 | #include <QLoggingCategory> | ||
30 | Q_DECLARE_LOGGING_CATEGORY(KWIN_XKB) | 29 | Q_DECLARE_LOGGING_CATEGORY(KWIN_XKB) | ||
31 | 30 | | |||
32 | #include <KSharedConfig> | | |||
33 | | ||||
34 | class QWindow; | | |||
35 | struct xkb_context; | 31 | struct xkb_context; | ||
36 | struct xkb_keymap; | 32 | struct xkb_keymap; | ||
37 | struct xkb_state; | 33 | struct xkb_state; | ||
38 | struct xkb_compose_table; | 34 | struct xkb_compose_table; | ||
39 | struct xkb_compose_state; | 35 | struct xkb_compose_state; | ||
40 | typedef uint32_t xkb_mod_index_t; | 36 | typedef uint32_t xkb_mod_index_t; | ||
41 | typedef uint32_t xkb_led_index_t; | 37 | typedef uint32_t xkb_led_index_t; | ||
42 | typedef uint32_t xkb_keysym_t; | 38 | typedef uint32_t xkb_keysym_t; | ||
43 | typedef uint32_t xkb_layout_index_t; | 39 | typedef uint32_t xkb_layout_index_t; | ||
44 | 40 | | |||
45 | namespace KWin | 41 | namespace KWin | ||
46 | { | 42 | { | ||
47 | 43 | | |||
48 | class InputRedirection; | | |||
49 | class KeyboardLayout; | | |||
50 | class ModifiersChangedSpy; | | |||
51 | class Toplevel; | | |||
52 | | ||||
53 | namespace LibInput | | |||
54 | { | | |||
55 | class Device; | | |||
56 | } | | |||
57 | | ||||
58 | class KWIN_EXPORT Xkb | 44 | class KWIN_EXPORT Xkb | ||
59 | { | 45 | { | ||
60 | public: | 46 | public: | ||
61 | Xkb(InputRedirection *input); | 47 | Xkb(InputRedirection *input); | ||
62 | ~Xkb(); | 48 | ~Xkb(); | ||
63 | void setConfig(KSharedConfigPtr config) { | 49 | void setConfig(KSharedConfigPtr config) { | ||
64 | m_config = config; | 50 | m_config = config; | ||
65 | } | 51 | } | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 96 | private: | |||
135 | struct { | 121 | struct { | ||
136 | xkb_compose_table *table = nullptr; | 122 | xkb_compose_table *table = nullptr; | ||
137 | xkb_compose_state *state = nullptr; | 123 | xkb_compose_state *state = nullptr; | ||
138 | } m_compose; | 124 | } m_compose; | ||
139 | LEDs m_leds; | 125 | LEDs m_leds; | ||
140 | KSharedConfigPtr m_config; | 126 | KSharedConfigPtr m_config; | ||
141 | }; | 127 | }; | ||
142 | 128 | | |||
143 | class KWIN_EXPORT KeyboardInputRedirection : public QObject | | |||
144 | { | | |||
145 | Q_OBJECT | | |||
146 | public: | | |||
147 | explicit KeyboardInputRedirection(InputRedirection *parent); | | |||
148 | virtual ~KeyboardInputRedirection(); | | |||
149 | | ||||
150 | void init(); | | |||
151 | | ||||
152 | void update(); | | |||
153 | | ||||
154 | /** | | |||
155 | * @internal | | |||
156 | */ | | |||
157 | void processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time, LibInput::Device *device = nullptr); | | |||
158 | /** | | |||
159 | * @internal | | |||
160 | */ | | |||
161 | void processModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); | | |||
162 | /** | | |||
163 | * @internal | | |||
164 | **/ | | |||
165 | void processKeymapChange(int fd, uint32_t size); | | |||
166 | | ||||
167 | Xkb *xkb() const { | | |||
168 | return m_xkb.data(); | | |||
169 | } | | |||
170 | Qt::KeyboardModifiers modifiers() const { | | |||
171 | return m_xkb->modifiers(); | | |||
172 | } | | |||
173 | Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { | | |||
174 | return m_xkb->modifiersRelevantForGlobalShortcuts(); | | |||
175 | } | | |||
176 | | ||||
177 | Q_SIGNALS: | | |||
178 | void ledsChanged(KWin::Xkb::LEDs); | | |||
179 | | ||||
180 | private: | | |||
181 | InputRedirection *m_input; | | |||
182 | bool m_inited = false; | | |||
183 | QScopedPointer<Xkb> m_xkb; | | |||
184 | QMetaObject::Connection m_activeClientSurfaceChangedConnection; | | |||
185 | ModifiersChangedSpy *m_modifiersChangedSpy = nullptr; | | |||
186 | KeyboardLayout *m_keyboardLayout = nullptr; | | |||
187 | }; | | |||
188 | | ||||
189 | inline | 129 | inline | ||
190 | Qt::KeyboardModifiers Xkb::modifiers() const | 130 | Qt::KeyboardModifiers Xkb::modifiers() const | ||
191 | { | 131 | { | ||
192 | return m_modifiers; | 132 | return m_modifiers; | ||
193 | } | 133 | } | ||
194 | 134 | | |||
195 | } | 135 | } | ||
196 | 136 | | |||
197 | Q_DECLARE_METATYPE(KWin::Xkb::LED) | 137 | Q_DECLARE_METATYPE(KWin::Xkb::LED) | ||
198 | Q_DECLARE_METATYPE(KWin::Xkb::LEDs) | 138 | Q_DECLARE_METATYPE(KWin::Xkb::LEDs) | ||
199 | 139 | | |||
200 | #endif | 140 | #endif |