Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qxkbcommon_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QXKBCOMMON_P_H
5#define QXKBCOMMON_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/qtguiglobal.h>
19#include <QtCore/qstring.h>
20#include <QtCore/qloggingcategory.h>
21#include <QtCore/qlist.h>
22#include <QtCore/private/qglobal_p.h>
23
24#include <xkbcommon/xkbcommon.h>
25
26#include <memory>
27
29
31
32class QEvent;
33class QKeyEvent;
35
36class Q_GUI_EXPORT QXkbCommon
37{
38public:
39 static QString lookupString(struct xkb_state *state, xkb_keycode_t code);
40 static QString lookupStringNoKeysymTransformations(xkb_keysym_t keysym);
41
42 static QList<xkb_keysym_t> toKeysym(QKeyEvent *event);
43
44 static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers);
45 static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers,
46 xkb_state *state, xkb_keycode_t code,
47 bool superAsMeta = true, bool hyperAsMeta = true);
48
49 // xkbcommon_* API is part of libxkbcommon internals, with modifications as
50 // described in the header of the implementation file.
51 static void xkbcommon_XConvertCase(xkb_keysym_t sym, xkb_keysym_t *lower, xkb_keysym_t *upper);
52 static xkb_keysym_t qxkbcommon_xkb_keysym_to_upper(xkb_keysym_t ks);
53
54 static Qt::KeyboardModifiers modifiers(struct xkb_state *state, xkb_keysym_t keysym = XKB_KEY_VoidSymbol);
55
56 static QList<int> possibleKeys(xkb_state *state, const QKeyEvent *event,
57 bool superAsMeta = false, bool hyperAsMeta = false);
58
59 static void verifyHasLatinLayout(xkb_keymap *keymap);
60 static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
61
62 static bool isLatin1(xkb_keysym_t sym) {
63 return sym >= 0x20 && sym <= 0xff;
64 }
65 static bool isKeypad(xkb_keysym_t sym) {
66 return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
67 }
68
69 static void setXkbContext(QPlatformInputContext *inputContext, struct xkb_context *context);
70
72 void operator()(struct xkb_state *state) const { return xkb_state_unref(state); }
73 };
75 void operator()(struct xkb_keymap *keymap) const { return xkb_keymap_unref(keymap); }
76 };
78 void operator()(struct xkb_context *context) const { return xkb_context_unref(context); }
79 };
80 using ScopedXKBState = std::unique_ptr<struct xkb_state, XKBStateDeleter>;
81 using ScopedXKBKeymap = std::unique_ptr<struct xkb_keymap, XKBKeymapDeleter>;
82 using ScopedXKBContext = std::unique_ptr<struct xkb_context, XKBContextDeleter>;
83};
84
86
87#endif // QXKBCOMMON_P_H
\inmodule QtCore
Definition qcoreevent.h:45
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
The QPlatformInputContext class abstracts the input method dependent data and composing state.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
std::unique_ptr< struct xkb_context, XKBContextDeleter > ScopedXKBContext
static bool isLatin1(xkb_keysym_t sym)
std::unique_ptr< struct xkb_keymap, XKBKeymapDeleter > ScopedXKBKeymap
std::unique_ptr< struct xkb_state, XKBStateDeleter > ScopedXKBState
static bool isKeypad(xkb_keysym_t sym)
EGLImageKHR int int EGLuint64KHR * modifiers
else opt state
[0]
Combined button and popup list for selecting options.
static void * context
#define Q_DECLARE_LOGGING_CATEGORY(name)
struct _cl_event * event
void operator()(struct xkb_context *context) const
void operator()(struct xkb_keymap *keymap) const
void operator()(struct xkb_state *state) const