1// Copyright (C) 2019 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#ifndef QCOMPOSEPLATFORMINPUTCONTEXT_H
4#define QCOMPOSEPLATFORMINPUTCONTEXT_H
5
6#include <QtCore/QLoggingCategory>
7
8#include <qpa/qplatforminputcontext.h>
9
10#include <xkbcommon/xkbcommon-compose.h>
11
12Q_DECLARE_OPAQUE_POINTER(xkb_context *)
13QT_BEGIN_NAMESPACE
14
15Q_DECLARE_LOGGING_CATEGORY(lcXkbCompose)
16
17class QEvent;
18
19class QComposeInputContext : public QPlatformInputContext
20{
21 Q_OBJECT
22public:
23 QComposeInputContext();
24 ~QComposeInputContext();
25
26 bool isValid() const override;
27 void setFocusObject(QObject *object) override;
28 void reset() override;
29 void update(Qt::InputMethodQueries) override;
30
31 bool filterEvent(const QEvent *event) override;
32
33 // This invokable is called from QXkbCommon::setXkbContext().
34 Q_INVOKABLE void setXkbContext(struct xkb_context *context) { m_XkbContext = context; }
35
36protected:
37 void ensureInitialized();
38
39private:
40 bool m_initialized = false;
41 xkb_compose_table *m_composeTable = nullptr;
42 xkb_compose_state *m_composeState = nullptr;
43 QObject *m_focusObject = nullptr;
44 struct xkb_context *m_XkbContext = nullptr;
45};
46
47QT_END_NAMESPACE
48
49#endif // QCOMPOSEPLATFORMINPUTCONTEXT_H
50

source code of qtbase/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.h