Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandtextinputv3_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWAYLANDTEXTINPUTV3_P_H
6#define QWAYLANDTEXTINPUTV3_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
20#include <QtWaylandClient/private/qwayland-text-input-unstable-v3.h>
21#include <QLoggingCategory>
22#include <QList>
23
24struct wl_callback;
25struct wl_callback_listener;
26
28
30
31namespace QtWaylandClient {
32
33class QWaylandDisplay;
34
36{
37public:
38 QWaylandTextInputv3(QWaylandDisplay *display, struct ::zwp_text_input_v3 *text_input);
39 ~QWaylandTextInputv3() override;
40
41 void reset() override;
42 void commit() override;
43 void updateState(Qt::InputMethodQueries queries, uint32_t flags) override;
44 // TODO: not supported yet
45 void setCursorInsidePreedit(int cursor) override;
46
47 bool isInputPanelVisible() const override;
48 QRectF keyboardRect() const override;
49
50 QLocale locale() const override;
51 Qt::LayoutDirection inputDirection() const override;
52
53 void showInputPanel() override;
54 void hideInputPanel() override;
55
56 // doing nothing in zwp_text_input_v3.
57 // enter() and leave() takes the role to enable/disable the surface
58 void enableSurface(::wl_surface *) override {};
59 void disableSurface(::wl_surface *) override {};
60
61protected:
62 void zwp_text_input_v3_enter(struct ::wl_surface *surface) override;
63 void zwp_text_input_v3_leave(struct ::wl_surface *surface) override;
64 void zwp_text_input_v3_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override;
65 void zwp_text_input_v3_commit_string(const QString &text) override;
66 void zwp_text_input_v3_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override;
67 void zwp_text_input_v3_done(uint32_t serial) override;
68 void zwp_text_input_v3_language(const QString &language) override;
69
70 void zwp_text_input_v3_action(uint32_t action, uint32_t serial) override;
71 void zwp_text_input_v3_preedit_hint(uint32_t begin, uint32_t end, uint32_t hint) override;
72
73private:
74 ::wl_surface *m_surface = nullptr; // ### Here for debugging purposes
75
76 struct StyleHint {
77 uint32_t begin = 0;
78 uint32_t end = 0;
79 preedit_hint hint;
80 bool operator==(const StyleHint &other) const {
81 return begin == other.begin && end == other.end && hint == other.hint;
82 }
83 };
84
85 struct PreeditInfo {
86 QString text;
87 int cursorBegin = 0;
88 int cursorEnd = 0;
89
90 QList<QWaylandTextInputv3::StyleHint> styleHints;
91
92 void clear() {
93 text.clear();
94 styleHints.clear();
95 cursorBegin = 0;
96 cursorEnd = 0;
97 }
98 friend bool operator==(const PreeditInfo& lhs, const PreeditInfo& rhs) {
99 return (lhs.text == rhs.text)
100 && (lhs.cursorBegin == rhs.cursorBegin)
101 && (lhs.cursorEnd == rhs.cursorEnd)
102 && lhs.styleHints == rhs.styleHints;
103 }
104 };
105
106 PreeditInfo m_pendingPreeditString;
107 PreeditInfo m_currentPreeditString;
108 QString m_pendingCommitString;
109 uint m_pendingDeleteBeforeText = 0; // byte length
110 uint m_pendingDeleteAfterText = 0; // byte length
111
112 QString m_surroundingText;
113 int m_cursor = 0; // cursor position in QString
114 int m_cursorPos = 0; // cursor position in wayland index
115 int m_anchorPos = 0; // anchor position in wayland index
116 uint32_t m_contentHint = 0;
117 uint32_t m_contentPurpose = 0;
118 QRect m_cursorRect;
119
120 uint m_currentSerial = 0;
121
122 bool m_condReselection = false;
123 QLocale m_locale;
124
125};
126
127}
128
129QT_END_NAMESPACE
130
131#endif // QWAYLANDTEXTINPUTV3_P_H
virtual void enableSurface(::wl_surface *surface)=0
virtual bool isInputPanelVisible() const =0
virtual QRectF keyboardRect() const =0
virtual void setCursorInsidePreedit(int cursor)=0
virtual void disableSurface(::wl_surface *surface)=0
virtual Qt::LayoutDirection inputDirection() const =0
virtual void updateState(Qt::InputMethodQueries queries, uint32_t flags)=0
void zwp_text_input_v1_language(uint32_t serial, const QString &language) override
void zwp_text_input_v1_keysym(uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override
void zwp_text_input_v1_enter(struct ::wl_surface *surface) override
void zwp_text_input_v1_input_panel_state(uint32_t state) override
Qt::LayoutDirection inputDirection() const override
void disableSurface(::wl_surface *surface) override
void zwp_text_input_v1_cursor_position(int32_t index, int32_t anchor) override
void zwp_text_input_v1_modifiers_map(wl_array *map) override
void zwp_text_input_v1_preedit_string(uint32_t serial, const QString &text, const QString &commit) override
void enableSurface(::wl_surface *surface) override
void zwp_text_input_v1_commit_string(uint32_t serial, const QString &text) override
void zwp_text_input_v1_delete_surrounding_text(int32_t before_length, uint32_t after_length) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void zwp_text_input_v1_preedit_cursor(int32_t index) override
void zwp_text_input_v1_text_direction(uint32_t serial, uint32_t direction) override
void zwp_text_input_v1_preedit_styling(uint32_t index, uint32_t length, uint32_t style) override
void setCursorInsidePreedit(int cursor) override
void zwp_text_input_v2_keysym(uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override
void zwp_text_input_v2_preedit_styling(uint32_t index, uint32_t length, uint32_t style) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void enableSurface(::wl_surface *surface) override
void zwp_text_input_v2_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override
void setCursorInsidePreedit(int cursor) override
void disableSurface(::wl_surface *surface) override
void zwp_text_input_v2_preedit_string(const QString &text, const QString &commit) override
void zwp_text_input_v2_input_method_changed(uint32_t serial, uint32_t flags) override
void zwp_text_input_v2_language(const QString &language) override
Qt::LayoutDirection inputDirection() const override
void zwp_text_input_v2_enter(uint32_t serial, struct ::wl_surface *surface) override
void zwp_text_input_v2_text_direction(uint32_t direction) override
void zwp_text_input_v2_modifiers_map(wl_array *map) override
void zwp_text_input_v2_commit_string(const QString &text) override
void zwp_text_input_v2_cursor_position(int32_t index, int32_t anchor) override
void zwp_text_input_v2_input_panel_state(uint32_t state, int32_t x, int32_t y, int32_t width, int32_t height) override
void zwp_text_input_v2_preedit_cursor(int32_t index) override
void zwp_text_input_v2_leave(uint32_t serial, struct ::wl_surface *surface) override
void disableSurface(::wl_surface *) override
void zwp_text_input_v3_commit_string(const QString &text) override
Qt::LayoutDirection inputDirection() const override
void zwp_text_input_v3_preedit_hint(uint32_t begin, uint32_t end, uint32_t hint) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void zwp_text_input_v3_enter(struct ::wl_surface *surface) override
void zwp_text_input_v3_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override
void zwp_text_input_v3_language(const QString &language) override
void zwp_text_input_v3_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override
void zwp_text_input_v3_leave(struct ::wl_surface *surface) override
void enableSurface(::wl_surface *) override
void setCursorInsidePreedit(int cursor) override
void zwp_text_input_v3_action(uint32_t action, uint32_t serial) override
void zwp_text_input_v3_done(uint32_t serial) override
Combined button and popup list for selecting options.
Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland")
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQIORing)