Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.6.2/qxcbkeyboard.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5 #ifndef QXCBKEYBOARD_H
6 #define QXCBKEYBOARD_H
7
8 #include "qxcbobject.h"
9
10 #include <xcb/xcb_keysyms.h>
11
12 #include <xkbcommon/xkbcommon.h>
13 #ifndef QT_NO_XKB
14 #include <xkbcommon/xkbcommon-x11.h>
15 #endif
16
17 #include <QEvent>
18
19 QT_BEGIN_NAMESPACE
20
21 class QWindow;
22
23 class QXcbKeyboard : public QXcbObject
24 {
25 public:
26 QXcbKeyboard(QXcbConnection *connection);
27
28 ~QXcbKeyboard();
29
30 void handleKeyPressEvent(const xcb_key_press_event_t *event);
31 void handleKeyReleaseEvent(const xcb_key_release_event_t *event);
32 void handleMappingNotifyEvent(const void *event);
33
34 Qt::KeyboardModifiers translateModifiers(int s) const;
35 void updateKeymap();
36 QList<int> possibleKeys(const QKeyEvent *e) const;
37
38 // when XKEYBOARD not present on the X server
39 void updateXKBMods();
40 quint32 xkbModMask(quint16 state);
41 void updateXKBStateFromCore(quint16 state);
42 #ifdef XCB_USE_XINPUT22
43 void updateXKBStateFromXI(void *modInfo, void *groupInfo);
44 #endif
45 #ifndef QT_NO_XKB
46 // when XKEYBOARD is present on the X server
47 int coreDeviceId() const { return core_device_id; }
48 void updateXKBState(xcb_xkb_state_notify_event_t *state);
49 #endif
50
51 protected:
52 void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
53
54 void resolveMaskConflicts();
55 QString lookupString(struct xkb_state *state, xcb_keycode_t code) const;
56 int keysymToQtKey(xcb_keysym_t keysym) const;
57 int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, const QString &text) const;
58 void printKeymapError(const char *error) const;
59
60 void readXKBConfig();
61 void clearXKBConfig();
62 // when XKEYBOARD not present on the X server
63 void updateModifiers();
64 // when XKEYBOARD is present on the X server
65 void updateVModMapping();
66 void updateVModToRModMapping();
67
68 xkb_keysym_t lookupLatinKeysym(xkb_keycode_t keycode) const;
69 void checkForLatinLayout();
70
71 private:
72 bool m_config;
73 xcb_keycode_t m_autorepeat_code;
74
75 struct xkb_context *xkb_context;
76 struct xkb_keymap *xkb_keymap;
77 struct xkb_state *xkb_state;
78 struct xkb_rule_names xkb_names;
79 mutable struct xkb_keymap *latin_keymap;
80
81 struct _mod_masks {
82 uint alt;
83 uint altgr;
84 uint meta;
85 uint super;
86 uint hyper;
87 };
88
89 _mod_masks rmod_masks;
90
91 // when XKEYBOARD not present on the X server
92 xcb_key_symbols_t *m_key_symbols;
93 struct _xkb_mods {
94 xkb_mod_index_t shift;
95 xkb_mod_index_t lock;
96 xkb_mod_index_t control;
97 xkb_mod_index_t mod1;
98 xkb_mod_index_t mod2;
99 xkb_mod_index_t mod3;
100 xkb_mod_index_t mod4;
101 xkb_mod_index_t mod5;
102 };
103 _xkb_mods xkb_mods;
104 #ifndef QT_NO_XKB
105 // when XKEYBOARD is present on the X server
106 _mod_masks vmod_masks;
107 int core_device_id;
108 #endif
109 bool m_hasLatinLayout;
110 };
111
112 QT_END_NAMESPACE
113
114 #endif