Debian Codegraph @

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