summaryrefslogtreecommitdiff
path: root/src/compositor/extensions/qwaylandqttextinputmethod_p.h
blob: e7b21d91325d5f83847c8fca2bef73b1f2989618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QWAYLANDQTTEXTINPUTMETHOD_P_H
#define QWAYLANDQTTEXTINPUTMETHOD_P_H


#include "qwaylandqttextinputmethod.h"

#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
#include <QtWaylandCompositor/private/qwayland-server-qt-text-input-method-unstable-v1.h>
#include <QtWaylandCompositor/qwaylanddestroylistener.h>

#include <QtCore/qrect.h>
#include <QtCore/qhash.h>

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

QT_BEGIN_NAMESPACE

class QWaylandCompositor;
class QWaylandSurface;

class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtTextInputMethodPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::qt_text_input_method_v1
{
    Q_DECLARE_PUBLIC(QWaylandQtTextInputMethod)
public:
    explicit QWaylandQtTextInputMethodPrivate(QWaylandCompositor *compositor);

    QWaylandCompositor *compositor;
    QWaylandSurface *focusedSurface = nullptr;
    Resource *resource = nullptr;
    QHash<Resource * , QWaylandSurface *> enabledSurfaces;
    QWaylandDestroyListener focusDestroyListener;
    bool inputPanelVisible = false;
    bool waitingForSync = false;

    Qt::InputMethodQueries updatingQueries;
    Qt::InputMethodHints hints;
    QString surroundingText;
    QString preferredLanguage;
    QRect cursorRectangle;
    int cursorPosition = 0;
    int anchorPosition = 0;
    int absolutePosition = 0;
    int surroundingTextOffset = 0;

private:
    void text_input_method_v1_enable(Resource *resource, struct ::wl_resource *surface) override;
    void text_input_method_v1_disable(Resource *resource, struct ::wl_resource *surface) override;
    void text_input_method_v1_destroy(Resource *resource) override;
    void text_input_method_v1_reset(Resource *resource) override;
    void text_input_method_v1_commit(Resource *resource) override;
    void text_input_method_v1_show_input_panel(Resource *resource) override;
    void text_input_method_v1_hide_input_panel(Resource *resource) override;
    void text_input_method_v1_update_hints(Resource *resource, int32_t hints) override;
    void text_input_method_v1_update_surrounding_text(Resource *resource, const QString &surroundingText, int32_t surroundingTextOffset) override;
    void text_input_method_v1_update_anchor_position(Resource *resource, int32_t anchorPosition) override;
    void text_input_method_v1_update_cursor_position(Resource *resource, int32_t cursorPosition) override;
    void text_input_method_v1_update_absolute_position(Resource *resource, int32_t absolutePosition) override;
    void text_input_method_v1_invoke_action(Resource *resource, int32_t type, int32_t cursorPosition) override;
    void text_input_method_v1_update_preferred_language(Resource *resource, const QString &preferredLanguage) override;
    void text_input_method_v1_update_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
    void text_input_method_v1_start_update(Resource *resource, int32_t queries) override;
    void text_input_method_v1_end_update(Resource *resource) override;
    void text_input_method_v1_acknowledge_input_method(Resource *resource) override;
};

QT_END_NAMESPACE

#endif // QWAYLANDQTTEXTINPUTMETHOD_P_H