Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandkeyboard_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:critical reason:network-protocol
5
6#ifndef QTWAYLAND_QWLKEYBOARD_P_H
7#define QTWAYLAND_QWLKEYBOARD_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
20
21#include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h>
22#include <QtWaylandCompositor/qwaylandseat.h>
23#include <QtWaylandCompositor/qwaylandkeyboard.h>
24#include <QtWaylandCompositor/qwaylanddestroylistener.h>
25
26#include <QtCore/private/qobject_p.h>
27#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
28
29#include <QtCore/QList>
30
31#if QT_CONFIG(xkbcommon)
32#include <xkbcommon/xkbcommon.h>
33#include <QtGui/private/qxkbcommon_p.h>
34#endif
35
36
38
39class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate
40 , public QtWaylandServer::wl_keyboard
41{
42public:
43 Q_DECLARE_PUBLIC(QWaylandKeyboard)
44
45 static QWaylandKeyboardPrivate *get(QWaylandKeyboard *keyboard);
46
47 QWaylandKeyboardPrivate(QWaylandSeat *seat);
48 ~QWaylandKeyboardPrivate() override;
49
50 QWaylandCompositor *compositor() const { return seat->compositor(); }
51
52 void focused(QWaylandSurface* surface);
53
54#if QT_CONFIG(xkbcommon)
55 struct xkb_state *xkbState() const { return mXkbState.get(); }
56 struct xkb_context *xkbContext() const {
57 return QWaylandCompositorPrivate::get(seat->compositor())->xkbContext();
58 }
59 uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
60 void maybeUpdateXkbScanCodeTable();
61 void resetKeyboardState();
62#endif
63
64 void keyEvent(uint code, uint32_t state);
65 void sendKeyEvent(uint code, uint32_t state);
66 void updateModifierState(uint code, uint32_t state);
67 void checkAndRepairModifierState(QKeyEvent *ke);
68 void maybeUpdateKeymap();
69
70 void checkFocusResource(Resource *resource);
71 void sendEnter(QWaylandSurface *surface, Resource *resource);
72
73protected:
74 void keyboard_bind_resource(Resource *resource) override;
75 void keyboard_destroy_resource(Resource *resource) override;
76 void keyboard_release(Resource *resource) override;
77
78private:
79#if QT_CONFIG(xkbcommon)
80 void createXKBKeymap();
81 void createXKBState(xkb_keymap *keymap);
82#endif
83 static uint toWaylandKey(const uint nativeScanCode);
84 static uint fromWaylandKey(const uint key);
85
86 void sendRepeatInfo();
87
88 QWaylandSeat *seat = nullptr;
89
90 QWaylandSurface *focus = nullptr;
91 Resource *focusResource = nullptr;
92 QWaylandDestroyListener focusDestroyListener;
93
94public:
95 QList<uint32_t> keys;
96 uint32_t modsDepressed = 0;
97 uint32_t modsLatched = 0;
98 uint32_t modsLocked = 0;
99 uint32_t group = 0;
100
101 uint32_t shiftIndex = 0;
102 uint32_t controlIndex = 0;
103 uint32_t altIndex = 0;
104 uint32_t mod5Index = 0; // AltGr (ISO_Level3_Shift) - maps to Qt::GroupSwitchModifier
105
106private:
107 Qt::KeyboardModifiers currentModifierState;
108
109 bool pendingKeymap = false;
110#if QT_CONFIG(xkbcommon)
111 size_t keymap_size;
112 int keymap_fd = -1;
113 char *keymap_area = nullptr;
114 using ScanCodeKey = std::pair<uint,int>; // group/layout and QtKey
115 QMap<ScanCodeKey, uint> scanCodesByQtKey;
116 QXkbCommon::ScopedXKBState mXkbState;
117#endif
118
119 quint32 repeatRate = 40;
120 quint32 repeatDelay = 400;
121};
122
123QT_END_NAMESPACE
124
125#endif // QTWAYLAND_QWLKEYBOARD_P_H
\inmodule QtWaylandCompositor
Combined button and popup list for selecting options.