diff options
author | Inho Lee <inho.lee@qt.io> | 2024-01-24 11:33:32 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-03-19 10:51:03 +0000 |
commit | 40ba380a188df50c2af438777d0d13e276c3cd82 (patch) | |
tree | 2d37d03a24ab43bfabbbaa8da03b5a04a4e507ea | |
parent | ce233c44a4b6e6fc52863c88efc43dbafad580b9 (diff) |
TextInputv3: use a serial for each resource
Each zwp_text_input_v3 object should have their own
serial number and it will not be cleared on the same object.
Change-Id: I779c2ae07f1dab1ae4a7d87e4e183ce33ec804fe
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Weng Xuetian <wengxt@gmail.com>
(cherry picked from commit e6f04ce6c1849009bcdc382e7e1da62afee029c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/client/qwaylandtextinputv3.cpp | 1 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandtextinputv3.cpp | 19 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandtextinputv3_p.h | 5 |
3 files changed, 9 insertions, 16 deletions
diff --git a/src/client/qwaylandtextinputv3.cpp b/src/client/qwaylandtextinputv3.cpp index 48f882feb..017456ac2 100644 --- a/src/client/qwaylandtextinputv3.cpp +++ b/src/client/qwaylandtextinputv3.cpp @@ -67,7 +67,6 @@ void QWaylandTextInputv3::zwp_text_input_v3_leave(struct ::wl_surface *surface) m_currentPreeditString.clear(); m_surface = nullptr; - m_currentSerial = 0U; disable(); qCDebug(qLcQpaWaylandTextInput) << Q_FUNC_INFO << "Done"; diff --git a/src/compositor/extensions/qwaylandtextinputv3.cpp b/src/compositor/extensions/qwaylandtextinputv3.cpp index 6fc1bcd16..3da89e630 100644 --- a/src/compositor/extensions/qwaylandtextinputv3.cpp +++ b/src/compositor/extensions/qwaylandtextinputv3.cpp @@ -126,7 +126,7 @@ void QWaylandTextInputV3Private::sendInputMethodEvent(QInputMethodEvent *event) } if (needsDone) - send_done(focusResource->handle, serial); + send_done(focusResource->handle, serials[focusResource]); } @@ -139,7 +139,7 @@ void QWaylandTextInputV3Private::sendKeyEvent(QKeyEvent *event) send_commit_string(focusResource->handle, event->text()); - send_done(focusResource->handle, serial); + send_done(focusResource->handle, serials[focusResource]); } QVariant QWaylandTextInputV3Private::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const @@ -188,7 +188,7 @@ QVariant QWaylandTextInputV3Private::inputMethodQuery(Qt::InputMethodQuery prope void QWaylandTextInputV3Private::setFocus(QWaylandSurface *surface) { - qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << surface; if (focusResource && focus) { // sync before leave @@ -225,13 +225,14 @@ void QWaylandTextInputV3Private::zwp_text_input_v3_bind_resource(Resource *resou { qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; - Q_UNUSED(resource); + serials.insert(resource, 0); } void QWaylandTextInputV3Private::zwp_text_input_v3_destroy_resource(Resource *resource) { qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + serials.remove(resource); if (focusResource == resource) focusResource = nullptr; } @@ -254,7 +255,6 @@ void QWaylandTextInputV3Private::zwp_text_input_v3_enable(Resource *resource) enabledSurfaces.insert(resource, focus); emit q->surfaceEnabled(focus); - serial = 0; inputPanelVisible = true; qApp->inputMethod()->show(); } @@ -293,12 +293,7 @@ void QWaylandTextInputV3Private::zwp_text_input_v3_commit(Resource *resource) { qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; - if (resource != focusResource) { - qCDebug(qLcWaylandCompositorTextInput) << "OBS: Disabled surface!!"; - return; - } - - serial = serial < UINT_MAX ? serial + 1U : 0U; + serials[resource] = serials[resource] < UINT_MAX ? serials[resource] + 1U : 0U; // Just increase serials and ignore empty commits if (!pendingState->changedState) { @@ -488,7 +483,7 @@ bool QWaylandTextInputV3::isSurfaceEnabled(QWaylandSurface *surface) const void QWaylandTextInputV3::add(::wl_client *client, uint32_t id, int version) { - qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO; + qCDebug(qLcWaylandCompositorTextInput) << Q_FUNC_INFO << client << id << version; Q_D(QWaylandTextInputV3); diff --git a/src/compositor/extensions/qwaylandtextinputv3_p.h b/src/compositor/extensions/qwaylandtextinputv3_p.h index ff03c82d5..ed43b88c6 100644 --- a/src/compositor/extensions/qwaylandtextinputv3_p.h +++ b/src/compositor/extensions/qwaylandtextinputv3_p.h @@ -73,9 +73,8 @@ public: QScopedPointer<QWaylandTextInputV3ClientState> currentState; QScopedPointer<QWaylandTextInputV3ClientState> pendingState; - uint32_t serial = 0; - - QHash<Resource *, QWaylandSurface*> enabledSurfaces; + QHash<Resource *, uint32_t> serials; + QHash<Resource *, QWaylandSurface *> enabledSurfaces; protected: void zwp_text_input_v3_bind_resource(Resource *resource) override; |