1// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
5#ifndef QWAYLANDINPUTCONTEXT_H
6#define QWAYLANDINPUTCONTEXT_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qpa/qplatforminputcontext.h>
20
21#include <QPointer>
22
23#include "qwaylandtextinputinterface_p.h"
24#include <qtwaylandclientglobal_p.h>
25#if QT_CONFIG(xkbcommon)
26#include <xkbcommon/xkbcommon-compose.h>
27#endif
28
29struct wl_callback;
30struct wl_callback_listener;
31
32QT_BEGIN_NAMESPACE
33
34namespace QtWaylandClient {
35
36class QWaylandDisplay;
37
38class QWaylandInputContext : public QPlatformInputContext
39{
40 Q_OBJECT
41public:
42 explicit QWaylandInputContext(QWaylandDisplay *display);
43 ~QWaylandInputContext() override;
44
45 bool isValid() const override;
46
47 void reset() override;
48 void commit() override;
49 void update(Qt::InputMethodQueries) override;
50
51 void invokeAction(QInputMethod::Action, int cursorPosition) override;
52
53 void showInputPanel() override;
54 void hideInputPanel() override;
55 bool isInputPanelVisible() const override;
56 QRectF keyboardRect() const override;
57
58 QLocale locale() const override;
59 Qt::LayoutDirection inputDirection() const override;
60
61 void setFocusObject(QObject *object) override;
62
63#if QT_CONFIG(xkbcommon)
64 bool filterEvent(const QEvent *event) override;
65
66 // This invokable is called from QXkbCommon::setXkbContext().
67 Q_INVOKABLE void setXkbContext(struct xkb_context *context) { m_XkbContext = context; }
68#endif
69
70private:
71 QWaylandTextInputInterface *textInput() const;
72
73 QWaylandDisplay *mDisplay = nullptr;
74 QPointer<QWindow> mCurrentWindow;
75
76#if QT_CONFIG(xkbcommon)
77 void ensureInitialized();
78
79 bool m_initialized = false;
80 QObject *m_focusObject = nullptr;
81 xkb_compose_table *m_composeTable = nullptr;
82 xkb_compose_state *m_composeState = nullptr;
83 struct xkb_context *m_XkbContext = nullptr;
84#endif
85};
86
87}
88
89QT_END_NAMESPACE
90
91#endif // QWAYLANDINPUTCONTEXT_H
92

source code of qtwayland/src/client/qwaylandinputcontext_p.h