Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.13.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 #if QT_CONFIG(xkb)
12 #define explicit dont_use_cxx_explicit
13 #include <xcb/xkb.h>
14 #undef explicit
15 #endif
16
17 #include <xkbcommon/xkbcommon.h>
18 #include <QtXkbCommonSupport/private/qxkbcommon_p.h>
19
20 #include <QEvent>
21
22 QT_BEGIN_NAMESPACE
23
24 class QXcbKeyboard : public QXcbObject
25 {
26 public:
27 QXcbKeyboard(QXcbConnection *connection);
28
29 ~QXcbKeyboard();
30
31 void initialize();
32 void selectEvents();
33
34 void handleKeyPressEvent(const xcb_key_press_event_t *event);
35 void handleKeyReleaseEvent(const xcb_key_release_event_t *event);
36
37 Qt::KeyboardModifiers translateModifiers(int s) const;
38 void updateKeymap(xcb_mapping_notify_event_t *event);
39 void updateKeymap();
40 QList<int> possibleKeys(const QKeyEvent *event) const;
41
42 // when XKEYBOARD not present on the X server
43 void updateXKBMods();
44 xkb_mod_mask_t xkbModMask(quint16 state);
45 void updateXKBStateFromCore(quint16 state);
46 #if QT_CONFIG(xcb_xinput)
47 void updateXKBStateFromXI(void *modInfo, void *groupInfo);
48 #endif
49 #if QT_CONFIG(xkb)
50 // when XKEYBOARD is present on the X server
51 int coreDeviceId() const { return core_device_id; }
52 void updateXKBState(xcb_xkb_state_notify_event_t *state);
53 #endif
54 void handleStateChanges(xkb_state_component changedComponents);
55
56 protected:
57 void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code,
58 quint16 state, xcb_timestamp_t time, bool fromSendEvent);
59
60 void resolveMaskConflicts();
61
62 typedef QMap<xcb_keysym_t, int> KeysymModifierMap;
63 struct xkb_keymap *keymapFromCore(const KeysymModifierMap &keysymMods);
64
65 // when XKEYBOARD not present on the X server
66 void updateModifiers(const KeysymModifierMap &keysymMods);
67 KeysymModifierMap keysymsToModifiers();
68 // when XKEYBOARD is present on the X server
69 void updateVModMapping();
70 void updateVModToRModMapping();
71
72 private:
73 bool m_config = false;
74 bool m_isAutoRepeat = false;
75 xcb_keycode_t m_autoRepeatCode = 0;
76
77 struct _mod_masks {
78 uint alt;
79 uint altgr;
80 uint meta;
81 uint super;
82 uint hyper;
83 };
84
85 _mod_masks rmod_masks;
86
87 // when XKEYBOARD not present on the X server
88 xcb_key_symbols_t *m_key_symbols = nullptr;
89 struct _xkb_mods {
90 xkb_mod_index_t shift;
91 xkb_mod_index_t lock;
92 xkb_mod_index_t control;
93 xkb_mod_index_t mod1;
94 xkb_mod_index_t mod2;
95 xkb_mod_index_t mod3;
96 xkb_mod_index_t mod4;
97 xkb_mod_index_t mod5;
98 };
99 _xkb_mods xkb_mods;
100 #if QT_CONFIG(xkb)
101 // when XKEYBOARD is present on the X server
102 _mod_masks vmod_masks;
103 int core_device_id;
104 #endif
105
106 QXkbCommon::ScopedXKBState m_xkbState;
107 QXkbCommon::ScopedXKBKeymap m_xkbKeymap;
108 QXkbCommon::ScopedXKBContext m_xkbContext;
109
110 bool m_superAsMeta = false;
111 bool m_hyperAsMeta = false;
112 };
113
114 QT_END_NAMESPACE
115
116 #endif