Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.15.6/qxcbkeyboard.h

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #ifndef QXCBKEYBOARD_H
41 #define QXCBKEYBOARD_H
42
43 #include "qxcbobject.h"
44
45 #include <xcb/xcb_keysyms.h>
46 #define explicit dont_use_cxx_explicit
47 #include <xcb/xkb.h>
48 #undef explicit
49
50 #include <QtXkbCommonSupport/private/qxkbcommon_p.h>
51 #include <xkbcommon/xkbcommon-x11.h>
52
53 #include <QEvent>
54
55 QT_BEGIN_NAMESPACE
56
57 class QXcbKeyboard : public QXcbObject
58 {
59 public:
60 QXcbKeyboard(QXcbConnection *connection);
61
62 ~QXcbKeyboard();
63
64 void initialize();
65 void selectEvents();
66
67 void handleKeyPressEvent(const xcb_key_press_event_t *event);
68 void handleKeyReleaseEvent(const xcb_key_release_event_t *event);
69
70 Qt::KeyboardModifiers translateModifiers(int s) const;
71 void updateKeymap(xcb_mapping_notify_event_t *event);
72 void updateKeymap();
73 QList<int> possibleKeys(const QKeyEvent *event) const;
74
75 void updateXKBMods();
76 xkb_mod_mask_t xkbModMask(quint16 state);
77 void updateXKBStateFromCore(quint16 state);
78 void updateXKBStateFromXI(void *modInfo, void *groupInfo);
79
80 int coreDeviceId() const { return core_device_id; }
81 void updateXKBState(xcb_xkb_state_notify_event_t *state);
82
83 void handleStateChanges(xkb_state_component changedComponents);
84
85 protected:
86 void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code,
87 quint16 state, xcb_timestamp_t time, bool fromSendEvent);
88
89 void resolveMaskConflicts();
90
91 typedef QMap<xcb_keysym_t, int> KeysymModifierMap;
92 struct xkb_keymap *keymapFromCore(const KeysymModifierMap &keysymMods);
93
94 void updateModifiers(const KeysymModifierMap &keysymMods);
95 KeysymModifierMap keysymsToModifiers();
96
97 void updateVModMapping();
98 void updateVModToRModMapping();
99
100 private:
101 bool m_config = false;
102 bool m_isAutoRepeat = false;
103 xcb_keycode_t m_autoRepeatCode = 0;
104
105 struct _mod_masks {
106 uint alt;
107 uint altgr;
108 uint meta;
109 uint super;
110 uint hyper;
111 };
112
113 _mod_masks rmod_masks;
114
115 xcb_key_symbols_t *m_key_symbols = nullptr;
116 struct _xkb_mods {
117 xkb_mod_index_t shift;
118 xkb_mod_index_t lock;
119 xkb_mod_index_t control;
120 xkb_mod_index_t mod1;
121 xkb_mod_index_t mod2;
122 xkb_mod_index_t mod3;
123 xkb_mod_index_t mod4;
124 xkb_mod_index_t mod5;
125 };
126 _xkb_mods xkb_mods;
127
128 _mod_masks vmod_masks;
129 int core_device_id;
130
131 QXkbCommon::ScopedXKBState m_xkbState;
132 QXkbCommon::ScopedXKBKeymap m_xkbKeymap;
133 QXkbCommon::ScopedXKBContext m_xkbContext;
134
135 bool m_superAsMeta = false;
136 bool m_hyperAsMeta = false;
137 };
138
139 QT_END_NAMESPACE
140
141 #endif