1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDQTTEXTINPUTMETHOD_P_H
5#define QWAYLANDQTTEXTINPUTMETHOD_P_H
6
7
8#include "qwaylandqttextinputmethod.h"
9
10#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
11#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h>
12#include <QtWaylandCompositor/qwaylanddestroylistener.h>
13
14#include <QtCore/qrect.h>
15#include <QtCore/qhash.h>
16
17//
18// W A R N I N G
19// -------------
20//
21// This file is not part of the Qt API. It exists purely as an
22// implementation detail. This header file may change from version to
23// version without notice, or even be removed.
24//
25// We mean it.
26//
27
28QT_BEGIN_NAMESPACE
29
30class QWaylandCompositor;
31class QWaylandSurface;
32
33class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1
34{
35 Q_DECLARE_PUBLIC(QWaylandQtTextInputMethod)
36public:
37 explicit QWaylandQtTextInputMethodPrivate(QWaylandCompositor *compositor);
38
39 QWaylandCompositor *compositor;
40 QWaylandSurface *focusedSurface = nullptr;
41 Resource *resource = nullptr;
42 QHash<Resource * , QWaylandSurface *> enabledSurfaces;
43 QWaylandDestroyListener focusDestroyListener;
44 bool inputPanelVisible = false;
45 bool waitingForSync = false;
46
47 Qt::InputMethodQueries updatingQueries;
48 Qt::InputMethodHints hints;
49 QString surroundingText;
50 QString preferredLanguage;
51 QRect cursorRectangle;
52 int cursorPosition = 0;
53 int anchorPosition = 0;
54 int absolutePosition = 0;
55 int surroundingTextOffset = 0;
56
57private:
58 void text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) override;
59 void text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) override;
60 void text_input_method_v1_destroy(Resource *resource) override;
61 void text_input_method_v1_reset(Resource *resource) override;
62 void text_input_method_v1_commit(Resource *resource) override;
63 void text_input_method_v1_show_input_panel(Resource *resource) override;
64 void text_input_method_v1_hide_input_panel(Resource *resource) override;
65 void text_input_method_v1_update_hints(Resource *resource, int32_t hints) override;
66 void text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) override;
67 void text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) override;
68 void text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) override;
69 void text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) override;
70 void text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) override;
71 void text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) override;
72 void text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
73 void text_input_method_v1_start_update(Resource *resource, int32_t queries) override;
74 void text_input_method_v1_end_update(Resource *resource) override;
75 void text_input_method_v1_acknowledge_input_method(Resource *resource) override;
76};
77
78QT_END_NAMESPACE
79
80#endif // QWAYLANDQTTEXTINPUTMETHOD_P_H
81

source code of qtwayland/src/compositor/extensions/qwaylandqttextinputmethod_p.h