diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-02-19 11:41:12 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-24 11:08:12 +0000 |
commit | 268e66f0b2561e6d2d65bb15067af6d959e30cce (patch) | |
tree | e0f305898fd2616f4b9bd6139a1fe918c66f723e | |
parent | 79ca28a428db86b65116baae2cb8752d1e925706 (diff) | |
download | qtwayland-268e66f0b2561e6d2d65bb15067af6d959e30cce.tar.gz |
Fix race condition when attaching client to text input
Extensions are registered by initialize(), which is called as
a polish event later. Therefore the following race can happen:
1. Application #1 requests a text-input object. The compositor
sees that the seat has no such object and creates a new one.
2. Polish event is posted.
3. Application #2 requests a text-input object. Since the
polish event is not yet processed, it also creates a new one.
4. Second polish event posted.
5. Both polish events processed.
We end up with two competing text-input objects, one per client.
This in turn leads to enter/leave events not being sent correctly,
and the client may therefore end up not updating the keyboard
hints.
The result was arbitrary behavior: Sometimes the keyboard
would not open at all, whereas other times it would open with
the current input method hints, even if these do not match the
hints of the editor.
[ChangeLog][Input] Fixed a problem where a virtual keyboard
would not be updated correctly if two clients were started
at almost the same time.
Fixes: QTBUG-91096
Change-Id: I262a5c15f87ba13d750425c259583919cd947ea4
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit e08b25efe4a7bec1004696bd23d9f8959158bd60)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp | 2 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandtextinputmanager.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp index b37c1a9b..271c3ec5 100644 --- a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp +++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp @@ -50,6 +50,8 @@ void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_t if (textInput == nullptr) textInput = new QWaylandQtTextInputMethod(seat, compositor); textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + if (!textInput->isInitialized()) + textInput->initialize(); } /*! diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp index 495ebae8..d9938d1f 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.cpp +++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp @@ -51,6 +51,8 @@ void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(R textInput = new QWaylandTextInput(seat, compositor); } textInput->add(resource->client(), id, wl_resource_get_version(resource->handle)); + if (!textInput->isInitialized()) + textInput->initialize(); } QWaylandTextInputManager::QWaylandTextInputManager() |