| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QWAYLANDTEXTINPUTV3_P_H |
| 5 | #define QWAYLANDTEXTINPUTV3_P_H |
| 6 | |
| 7 | #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> |
| 8 | #include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v3.h> |
| 9 | #include <QtWaylandCompositor/QWaylandDestroyListener> |
| 10 | |
| 11 | #include <QtCore/QObject> |
| 12 | #include <QtCore/QRect> |
| 13 | #include <QtGui/QInputMethod> |
| 14 | #include <QtWaylandCompositor/QWaylandSurface> |
| 15 | |
| 16 | // |
| 17 | // W A R N I N G |
| 18 | // ------------- |
| 19 | // |
| 20 | // This file is not part of the Qt API. It exists purely as an |
| 21 | // implementation detail. This header file may change from version to |
| 22 | // version without notice, or even be removed. |
| 23 | // |
| 24 | // We mean it. |
| 25 | // |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | class QInputMethodEvent; |
| 30 | class QKeyEvent; |
| 31 | class QWaylandCompositor; |
| 32 | class QWaylandView; |
| 33 | |
| 34 | class QWaylandTextInputV3ClientState { |
| 35 | public: |
| 36 | QWaylandTextInputV3ClientState(); |
| 37 | |
| 38 | Qt::InputMethodQueries updatedQueries(const QWaylandTextInputV3ClientState &other) const; |
| 39 | Qt::InputMethodQueries mergeChanged(const QWaylandTextInputV3ClientState &other); |
| 40 | |
| 41 | Qt::InputMethodHints hints = Qt::ImhNone; |
| 42 | QRect cursorRectangle; |
| 43 | QString surroundingText; |
| 44 | int cursorPosition = 0; |
| 45 | int anchorPosition = 0; |
| 46 | |
| 47 | Qt::InputMethodQueries changedState; |
| 48 | }; |
| 49 | |
| 50 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextInputV3Private : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v3 |
| 51 | { |
| 52 | Q_DECLARE_PUBLIC(QWaylandTextInputV3) |
| 53 | public: |
| 54 | explicit QWaylandTextInputV3Private(QWaylandCompositor *compositor); |
| 55 | |
| 56 | void sendInputMethodEvent(QInputMethodEvent *event); |
| 57 | void sendKeyEvent(QKeyEvent *event); |
| 58 | |
| 59 | QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const; |
| 60 | |
| 61 | void setFocus(QWaylandSurface *surface); |
| 62 | |
| 63 | QWaylandCompositor *compositor = nullptr; |
| 64 | |
| 65 | QWaylandSurface *focus = nullptr; |
| 66 | Resource *focusResource = nullptr; |
| 67 | QWaylandDestroyListener focusDestroyListener; |
| 68 | |
| 69 | bool inputPanelVisible = false; |
| 70 | |
| 71 | QString currentPreeditString; |
| 72 | |
| 73 | QScopedPointer<QWaylandTextInputV3ClientState> currentState; |
| 74 | QScopedPointer<QWaylandTextInputV3ClientState> pendingState; |
| 75 | |
| 76 | QHash<Resource *, uint32_t> serials; |
| 77 | QHash<Resource *, QWaylandSurface *> enabledSurfaces; |
| 78 | |
| 79 | protected: |
| 80 | void zwp_text_input_v3_bind_resource(Resource *resource) override; |
| 81 | void zwp_text_input_v3_destroy_resource(Resource *resource) override; |
| 82 | |
| 83 | void zwp_text_input_v3_destroy(Resource *resource) override; |
| 84 | void zwp_text_input_v3_enable(Resource *resource) override; |
| 85 | void zwp_text_input_v3_disable(Resource *resource) override; |
| 86 | void zwp_text_input_v3_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) override; |
| 87 | void zwp_text_input_v3_set_text_change_cause(Resource *resource, uint32_t cause) override; |
| 88 | void zwp_text_input_v3_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override; |
| 89 | void zwp_text_input_v3_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; |
| 90 | void zwp_text_input_v3_commit(Resource *resource) override; |
| 91 | }; |
| 92 | |
| 93 | QT_END_NAMESPACE |
| 94 | |
| 95 | #endif // QWAYLANDTEXTINPUTV3_P_H |
| 96 | |