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 QWAYLANDINPUTV2_P_H
6#define QWAYLANDINPUTV2_P_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 "qwaylandtextinputinterface_p.h"
20#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
21#include <qwaylandinputmethodeventbuilder_p.h>
22
23struct wl_callback;
24struct wl_callback_listener;
25
26QT_BEGIN_NAMESPACE
27
28namespace QtWaylandClient {
29
30class QWaylandDisplay;
31
32class QWaylandTextInputv2 : public QtWayland::zwp_text_input_v2, public QWaylandTextInputInterface
33{
34public:
35 QWaylandTextInputv2(QWaylandDisplay *display, struct ::zwp_text_input_v2 *text_input);
36 ~QWaylandTextInputv2() override;
37
38 void reset() override;
39 void commit() override;
40 void updateState(Qt::InputMethodQueries queries, uint32_t flags) override;
41
42 void setCursorInsidePreedit(int cursor) override;
43
44 bool isInputPanelVisible() const override;
45 QRectF keyboardRect() const override;
46
47 QLocale locale() const override;
48 Qt::LayoutDirection inputDirection() const override;
49
50 void showInputPanel() override
51 {
52 show_input_panel();
53 }
54 void hideInputPanel() override
55 {
56 hide_input_panel();
57 }
58 void enableSurface(::wl_surface *surface) override
59 {
60 enable(surface);
61 }
62 void disableSurface(::wl_surface *surface) override
63 {
64 disable(surface);
65 }
66
67protected:
68 void zwp_text_input_v2_enter(uint32_t serial, struct ::wl_surface *surface) override;
69 void zwp_text_input_v2_leave(uint32_t serial, struct ::wl_surface *surface) override;
70 void zwp_text_input_v2_modifiers_map(wl_array *map) override;
71 void zwp_text_input_v2_input_panel_state(uint32_t state, int32_t x, int32_t y, int32_t width, int32_t height) override;
72 void zwp_text_input_v2_preedit_string(const QString &text, const QString &commit) override;
73 void zwp_text_input_v2_preedit_styling(uint32_t index, uint32_t length, uint32_t style) override;
74 void zwp_text_input_v2_preedit_cursor(int32_t index) override;
75 void zwp_text_input_v2_commit_string(const QString &text) override;
76 void zwp_text_input_v2_cursor_position(int32_t index, int32_t anchor) override;
77 void zwp_text_input_v2_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override;
78 void zwp_text_input_v2_keysym(uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override;
79 void zwp_text_input_v2_language(const QString &language) override;
80 void zwp_text_input_v2_text_direction(uint32_t direction) override;
81 void zwp_text_input_v2_input_method_changed(uint32_t serial, uint32_t flags) override;
82
83private:
84 Qt::KeyboardModifiers modifiersToQtModifiers(uint32_t modifiers);
85
86 QWaylandDisplay *m_display = nullptr;
87 QWaylandInputMethodEventBuilder m_builder;
88
89 QList<Qt::KeyboardModifier> m_modifiersMap;
90
91 uint32_t m_serial = 0;
92 struct ::wl_surface *m_surface = nullptr;
93
94 QString m_preeditCommit;
95
96 bool m_inputPanelVisible = false;
97 QRectF m_keyboardRectangle;
98 QLocale m_locale;
99 Qt::LayoutDirection m_inputDirection = Qt::LayoutDirectionAuto;
100
101 struct ::wl_callback *m_resetCallback = nullptr;
102 static const wl_callback_listener callbackListener;
103 static void resetCallback(void *data, struct wl_callback *wl_callback, uint32_t time);
104};
105
106}
107
108QT_END_NAMESPACE
109
110#endif // QWAYLANDTEXTINPUTV2_P_H
111

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