Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.5.1/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 void updateXKBStateFromXI(void *modInfo, void *groupInfo);
43 #ifndef QT_NO_XKB
44 // when XKEYBOARD is present on the X server
45 int coreDeviceId() const { return core_device_id; }
46 void updateXKBState(xcb_xkb_state_notify_event_t *state);
47 #endif
48
49 protected:
50 void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
51
52 void resolveMaskConflicts();
53 QString lookupString(struct xkb_state *state, xcb_keycode_t code) const;
54 int keysymToQtKey(xcb_keysym_t keysym) const;
55 int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, const QString &text) const;
56 void printKeymapError(const char *error) const;
57
58 void readXKBConfig();
59 void clearXKBConfig();
60 // when XKEYBOARD not present on the X server
61 void updateModifiers();
62 // when XKEYBOARD is present on the X server
63 void updateVModMapping();
64 void updateVModToRModMapping();
65
66 xkb_keysym_t lookupLatinKeysym(xkb_keycode_t keycode) const;
67 void checkForLatinLayout();
68
69 private:
70 bool m_config;
71 xcb_keycode_t m_autorepeat_code;
72
73 struct xkb_context *xkb_context;
74 struct xkb_keymap *xkb_keymap;
75 struct xkb_state *xkb_state;
76 struct xkb_rule_names xkb_names;
77 mutable struct xkb_keymap *latin_keymap;
78
79 struct _mod_masks {
80 uint alt;
81 uint altgr;
82 uint meta;
83 uint super;
84 uint hyper;
85 };
86
87 _mod_masks rmod_masks;
88
89 // when XKEYBOARD not present on the X server
90 xcb_key_symbols_t *m_key_symbols;
91 struct _xkb_mods {
92 xkb_mod_index_t shift;
93 xkb_mod_index_t lock;
94 xkb_mod_index_t control;
95 xkb_mod_index_t mod1;
96 xkb_mod_index_t mod2;
97 xkb_mod_index_t mod3;
98 xkb_mod_index_t mod4;
99 xkb_mod_index_t mod5;
100 };
101 _xkb_mods xkb_mods;
102 #ifndef QT_NO_XKB
103 // when XKEYBOARD is present on the X server
104 _mod_masks vmod_masks;
105 int core_device_id;
106 #endif
107 bool m_hasLatinLayout;
108 };
109
110 QT_END_NAMESPACE
111
112 #endif