diff options
author | Dominik Holland <dominik.holland@qt.io> | 2020-06-08 15:55:11 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2022-03-15 13:59:17 +0100 |
commit | 2f1b74e5b325fc4f44143c53507a31fe59bd8003 (patch) | |
tree | b59226851b183023dec3ae77249383d891a875aa | |
parent | 484af9cb042c075815200e571695b881b9e6130c (diff) |
Also accept a client text-input extension registered too late
When the wayland surface gets initialized at the compositor
side, the compositor checks whether the text-input extension
is available and connects to its signal.
If the client doesn't create the extension before the
initialization on the compositor side happens, the
InputMethodControl of the surface is not connected to the
text-input extension and doesn't work correctly.
In this case the connection should be made once the extension
is available.
Change-Id: Icdd015f1d7853fe2f191b91a87d25f196f6b7769
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
3 files changed, 21 insertions, 6 deletions
diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp index be019b5b0..2186a0401 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.cpp @@ -47,12 +47,8 @@ QWaylandInputMethodControl::QWaylandInputMethodControl(QWaylandSurface *surface) { connect(d_func()->compositor, &QWaylandCompositor::defaultSeatChanged, this, &QWaylandInputMethodControl::defaultSeatChanged); - QWaylandTextInput *textInput = d_func()->textInput(); - if (textInput) { - connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled); - connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled); - connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod); - } + + updateTextInput(); #if QT_WAYLAND_TEXT_INPUT_V4_WIP QWaylandTextInputV4 *textInputV4 = d_func()->textInputV4(); @@ -165,6 +161,17 @@ void QWaylandInputMethodControl::setSurface(QWaylandSurface *surface) || (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface))); } +void QWaylandInputMethodControl::updateTextInput() +{ + QWaylandTextInput *textInput = d_func()->textInput(); + + if (textInput) { + connect(textInput, &QWaylandTextInput::surfaceEnabled, this, &QWaylandInputMethodControl::surfaceEnabled, Qt::UniqueConnection); + connect(textInput, &QWaylandTextInput::surfaceDisabled, this, &QWaylandInputMethodControl::surfaceDisabled, Qt::UniqueConnection); + connect(textInput, &QWaylandTextInput::updateInputMethod, this, &QWaylandInputMethodControl::updateInputMethod, Qt::UniqueConnection); + } +} + void QWaylandInputMethodControl::defaultSeatChanged() { Q_D(QWaylandInputMethodControl); diff --git a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h index 8cb4a2ea6..b32d6549b 100644 --- a/src/compositor/compositor_api/qwaylandinputmethodcontrol.h +++ b/src/compositor/compositor_api/qwaylandinputmethodcontrol.h @@ -39,6 +39,7 @@ class QWaylandCompositor; class QWaylandInputMethodControlPrivate; class QWaylandSurface; class QInputMethodEvent; +class QWaylandTextInput; class QWaylandInputMethodControl : public QObject { @@ -58,6 +59,7 @@ public: void setEnabled(bool enabled); void setSurface(QWaylandSurface *surface); + void updateTextInput(); Q_SIGNALS: void enabledChanged(bool enabled); diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index 6be9c0cde..845ee6f7c 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -36,6 +36,7 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" #include "qwaylandinputmethodeventbuilder_p.h" +#include "qwaylandinputmethodcontrol.h" #include <QGuiApplication> #include <QInputMethodEvent> @@ -335,6 +336,11 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_enable(Resource *resource, wl_r QWaylandSurface *s = QWaylandSurface::fromResource(surface); enabledSurfaces.insert(resource, s); + + QWaylandInputMethodControl *control = s->inputMethodControl(); + if (control) + control->updateTextInput(); + emit q->surfaceEnabled(s); } |