From c9c05c38996ba71698095e6d6968b9e1b124c0f7 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Fri, 2 Oct 2020 16:31:59 +0530 Subject: [PATCH] input-method-v2: pass the reason state was updated to compositor This removes the signals the requestReset and stateCommitted and replaces it with single stateUpdated signal. --- .../autotests/client/test_text_input_v2.cpp | 6 +++--- src/wayland/textinput_v2_interface.cpp | 15 +-------------- src/wayland/textinput_v2_interface.h | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/wayland/autotests/client/test_text_input_v2.cpp b/src/wayland/autotests/client/test_text_input_v2.cpp index 7de343a3a8..cec1d2125d 100644 --- a/src/wayland/autotests/client/test_text_input_v2.cpp +++ b/src/wayland/autotests/client/test_text_input_v2.cpp @@ -378,11 +378,11 @@ void TextInputTest::testReset() auto ti = m_seatInterface->textInputV2(); QVERIFY(ti); - QSignalSpy resetRequestedSpy(ti, &TextInputV2Interface::requestReset); - QVERIFY(resetRequestedSpy.isValid()); + QSignalSpy stateUpdatedSpy(ti, &TextInputV2Interface::stateUpdated); + QVERIFY(stateUpdatedSpy.isValid()); textInput->reset(); - QVERIFY(resetRequestedSpy.wait()); + QVERIFY(stateUpdatedSpy.wait()); } void TextInputTest::testSurroundingText() diff --git a/src/wayland/textinput_v2_interface.cpp b/src/wayland/textinput_v2_interface.cpp index 8e93b300d0..5ab18dbcbb 100644 --- a/src/wayland/textinput_v2_interface.cpp +++ b/src/wayland/textinput_v2_interface.cpp @@ -301,20 +301,7 @@ void TextInputV2InterfacePrivate::zwp_text_input_v2_disable(Resource *resource, void TextInputV2InterfacePrivate::zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t reason) { Q_UNUSED(resource) - switch (reason) { - case update_state::update_state_change: - break; - case update_state::update_state_full: - break; - case update_state::update_state_enter: - break; - case update_state::update_state_reset: - emit q->requestReset(); - break; - default: - return; - } - emit q->stateCommitted(serial); + emit q->stateUpdated(serial, TextInputV2Interface::UpdateReason(reason)); } void TextInputV2InterfacePrivate::zwp_text_input_v2_hide_input_panel(Resource *resource) diff --git a/src/wayland/textinput_v2_interface.h b/src/wayland/textinput_v2_interface.h index 10e8d7a033..efdda6417a 100644 --- a/src/wayland/textinput_v2_interface.h +++ b/src/wayland/textinput_v2_interface.h @@ -9,6 +9,7 @@ #include #include + #include "textinput.h" struct wl_resource; @@ -67,6 +68,12 @@ class KWAYLANDSERVER_EXPORT TextInputV2Interface : public QObject public: ~TextInputV2Interface() override; + enum class UpdateReason : uint32_t { + StateChange = 0, // updated state because it changed + StateFull = 1, // full state after enter or input_method_changed event + StateReset = 2, // full state after reset + StateEnter = 3, // full state after switching focus to a different widget on client side + }; /** * The preferred language as a RFC-3066 format language tag. * @@ -219,12 +226,6 @@ Q_SIGNALS: * @see requestShowInputPanel **/ void requestHideInputPanel(); - /** - * Invoked by the client when the input state should be - * reset, for example after the text was changed outside of the normal - * input method flow. - **/ - void requestReset(); /** * Emitted whenever the preferred @p language changes. * @see preferredLanguage @@ -255,10 +256,9 @@ Q_SIGNALS: **/ void enabledChanged(); /** - * Emitted whenever TextInputInterface should commit the current state. - * @see requestReset + * Emitted whenever TextInputInterface should update the current state. **/ - void stateCommitted(uint32_t serial); + void stateUpdated(uint32_t serial, UpdateReason reason); private: friend class TextInputManagerV2InterfacePrivate; @@ -272,5 +272,6 @@ private: } Q_DECLARE_METATYPE(KWaylandServer::TextInputV2Interface *) +Q_DECLARE_METATYPE(KWaylandServer::TextInputV2Interface::UpdateReason) #endif