16#include <QtGui/QInputMethodEvent>
18QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface)
19 : QObject(*
new QWaylandInputMethodControlPrivate(surface), surface)
21 connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged,
22 this, &QWaylandInputMethodControl::defaultSeatChanged);
26 QWaylandTextInputV3 *textInputV3 = d_func()->textInputV3();
28 connect(textInputV3, &QWaylandTextInputV3::surfaceEnabled,
this, &QWaylandInputMethodControl::surfaceEnabled);
29 connect(textInputV3, &QWaylandTextInputV3::surfaceDisabled,
this, &QWaylandInputMethodControl::surfaceDisabled);
30 connect(textInputV3, &QWaylandTextInputV3::updateInputMethod,
this, &QWaylandInputMethodControl::updateInputMethod);
33 QWaylandQtTextInputMethod *textInputMethod = d_func()->textInputMethod();
34 if (textInputMethod) {
35 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceEnabled,
this, &QWaylandInputMethodControl::surfaceEnabled);
36 connect(textInputMethod, &QWaylandQtTextInputMethod::surfaceDisabled,
this, &QWaylandInputMethodControl::surfaceDisabled);
37 connect(textInputMethod, &QWaylandQtTextInputMethod::updateInputMethod,
this, &QWaylandInputMethodControl::updateInputMethod);
43 Q_D(
const QWaylandInputMethodControl);
46 if (textInput !=
nullptr && textInput->focus() == d->surface)
47 return textInput->inputMethodQuery(query, argument);
50 if (textInputV3 !=
nullptr && textInputV3->focus() == d->surface)
51 return textInputV3->inputMethodQuery(query, argument);
54 if (textInputMethod && textInputMethod->focusedSurface() == d->surface)
55 return textInputMethod->inputMethodQuery(query, argument);
62 Q_D(QWaylandInputMethodControl);
76
77
78
79
80
81
82
83
86 Q_D(
const QWaylandInputMethodControl);
93 Q_D(QWaylandInputMethodControl);
95 if (d->enabled == enabled)
99 emit enabledChanged(enabled);
100 emit updateInputMethod(Qt::ImQueryInput);
105 Q_D(QWaylandInputMethodControl);
107 if (surface == d->surface)
113 Q_D(QWaylandInputMethodControl);
115 if (surface == d->surface)
121 Q_D(QWaylandInputMethodControl);
123 if (d->surface == surface)
126 d->surface = surface;
143 connect(textInput, &QWaylandTextInput::updateInputMethod,
this, &QWaylandInputMethodControl::updateInputMethod, Qt::UniqueConnection);
149 Q_D(QWaylandInputMethodControl);
151 disconnect(d->textInput(),
nullptr,
this,
nullptr);
152 disconnect(d->textInputV3(),
nullptr,
this,
nullptr);
153 disconnect(d->textInputMethod(),
nullptr,
this,
nullptr);
155 d->seat = d->compositor->defaultSeat();
170 if (textInputMethod) {
180QWaylandInputMethodControlPrivate::QWaylandInputMethodControlPrivate(QWaylandSurface *surface)
181 : compositor(surface->compositor())
182 , seat(compositor->defaultSeat())
187QWaylandQtTextInputMethod *QWaylandInputMethodControlPrivate::textInputMethod()
const
189 if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1))
191 return QWaylandQtTextInputMethod::findIn(seat);
194QWaylandTextInput *QWaylandInputMethodControlPrivate::textInput()
const
196 if (!surface->client() || !surface->client()->textInputProtocols().testFlag(QWaylandClient::TextInputProtocol::TextInputV2))
198 return QWaylandTextInput::findIn(seat);
201QWaylandTextInputV3 *QWaylandInputMethodControlPrivate::textInputV3()
const
203 return QWaylandTextInputV3::findIn(seat);
206#include "moc_qwaylandinputmethodcontrol.cpp"
bool isSurfaceEnabled(QWaylandSurface *surface) const
void surfaceEnabled(QWaylandSurface *surface)
void sendInputMethodEvent(QInputMethodEvent *event)
void surfaceDisabled(QWaylandSurface *surface)
void surfaceEnabled(QWaylandSurface *surface)
void sendInputMethodEvent(QInputMethodEvent *event)
void surfaceDisabled(QWaylandSurface *surface)
bool isSurfaceEnabled(QWaylandSurface *surface) const
void sendInputMethodEvent(QInputMethodEvent *event)
void surfaceDisabled(QWaylandSurface *surface)
bool isSurfaceEnabled(QWaylandSurface *surface) const
void surfaceEnabled(QWaylandSurface *surface)