Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwaylandinputmethodcontrol.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
6
8#include "qwaylandseat.h"
9#include "qwaylandsurface.h"
10#include "qwaylandview.h"
11#include "qwaylandtextinput.h"
12#include "qwaylandtextinputv3.h"
14
15#include <QtGui/QInputMethodEvent>
16
18 : QObject(*new QWaylandInputMethodControlPrivate(surface), surface)
19{
20 connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged,
21 this, &QWaylandInputMethodControl::defaultSeatChanged);
22
24
25 QWaylandTextInputV3 *textInputV3 = d_func()->textInputV3();
26 if (textInputV3) {
27 connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
28 connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
30 }
31
32 QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod();
33 if (textInputMethod) {
34 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
35 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
37 }
38}
39
41{
43
44 QWaylandTextInput *textInput = d->textInput();
45 if (textInput != nullptr && textInput->focus() == d->surface)
46 return textInput->inputMethodQuery(query, argument);
47
48 QWaylandTextInputV3 *textInputV3 = d->textInputV3();
49 if (textInputV3 != nullptr && textInputV3->focus() == d->surface)
50 return textInputV3->inputMethodQuery(query, argument);
51
52 QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod();
53 if (textInputMethod && textInputMethod->focusedSurface() == d->surface)
54 return textInputMethod->inputMethodQuery(query, argument);
55
56 return QVariant();
57}
58
60{
62
63 if (QWaylandTextInput *textInput = d->textInput()) {
64 textInput->sendInputMethodEvent(event);
65 } else if (QWaylandTextInputV3 *textInputV3 = d->textInputV3()) {
66 textInputV3->sendInputMethodEvent(event);
67 } else if (QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod()) {
68 textInputMethod->sendInputMethodEvent(event);
69 } else {
70 event->ignore();
71 }
72}
73
75{
77
78 return d->enabled;
79}
80
82{
84
85 if (d->enabled == enabled)
86 return;
87
88 d->enabled = enabled;
91}
92
93void QWaylandInputMethodControl::surfaceEnabled(QWaylandSurface *surface)
94{
96
97 if (surface == d->surface)
98 setEnabled(true);
99}
100
101void QWaylandInputMethodControl::surfaceDisabled(QWaylandSurface *surface)
102{
104
105 if (surface == d->surface)
106 setEnabled(false);
107}
108
110{
112
113 if (d->surface == surface)
114 return;
115
116 d->surface = surface;
117
118 QWaylandTextInput *textInput = d->textInput();
119 QWaylandTextInputV3 *textInputV3 = d->textInputV3();
120 QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod();
121 setEnabled((textInput && textInput->isSurfaceEnabled(d->surface))
122 || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface))
123 || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface)));
124}
125
127{
128 QWaylandTextInput *textInput = d_func()->textInput();
129
130 if (textInput) {
131 connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled, Qt::UniqueConnection);
132 connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled, Qt::UniqueConnection);
134 }
135}
136
137void QWaylandInputMethodControl::defaultSeatChanged()
138{
140
141 disconnect(d->textInput(), nullptr, this, nullptr);
142 disconnect(d->textInputV3(), nullptr, this, nullptr);
143 disconnect(d->textInputMethod(), nullptr, this, nullptr);
144
145 d->seat = d->compositor->defaultSeat();
146 QWaylandTextInput *textInput = d->textInput();
147 QWaylandTextInputV3 *textInputV3 = d->textInputV3();
148 QWaylandQtTextInputMethod *textInputMethod = d->textInputMethod();
149
150 if (textInput) {
151 connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
152 connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
153 }
154
155 if (textInputV3) {
156 connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
157 connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
158 }
159
160 if (textInputMethod) {
161 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled);
162 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled);
163 }
164
165 setEnabled((textInput && textInput->isSurfaceEnabled(d->surface))
166 || (textInputV3 && textInputV3->isSurfaceEnabled(d->surface))
167 || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface)));
168}
169
171 : compositor(surface->compositor())
172 , seat(compositor->defaultSeat())
173 , surface(surface)
174{
175}
176
183
190
195
196#include "moc_qwaylandinputmethodcontrol.cpp"
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore
Definition qvariant.h:65
TextInputProtocols textInputProtocols() const
static QWaylandQtTextInputMethod * findIn(QWaylandObject *container)
If any instance of the interface has been registered with container, this is returned.
QWaylandInputMethodControlPrivate(QWaylandSurface *surface)
QWaylandQtTextInputMethod * textInputMethod() const
void enabledChanged(bool enabled)
QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
void inputMethodEvent(QInputMethodEvent *event)
void updateInputMethod(Qt::InputMethodQueries queries)
QWaylandInputMethodControl(QWaylandSurface *surface)
void setSurface(QWaylandSurface *surface)
void updateInputMethod(Qt::InputMethodQueries queries)
bool isSurfaceEnabled(QWaylandSurface *surface) const
void surfaceEnabled(QWaylandSurface *surface)
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
QWaylandSurface * focusedSurface() const
void surfaceDisabled(QWaylandSurface *surface)
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
QWaylandClient * client
\qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client
void surfaceEnabled(QWaylandSurface *surface)
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
void surfaceDisabled(QWaylandSurface *surface)
void updateInputMethod(Qt::InputMethodQueries queries)
QWaylandSurface * focus() const
bool isSurfaceEnabled(QWaylandSurface *surface) const
void surfaceDisabled(QWaylandSurface *surface)
void updateInputMethod(Qt::InputMethodQueries queries)
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
bool isSurfaceEnabled(QWaylandSurface *surface) const
void surfaceEnabled(QWaylandSurface *surface)
QWaylandSurface * focus() const
InputMethodQuery
@ ImQueryInput
@ UniqueConnection
static QOpenGLCompositor * compositor
GLenum GLenum GLsizei const GLuint GLboolean enabled
struct _cl_event * event
GLenum query
#define emit
myObject disconnect()
[26]
QDBusArgument argument