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.
This commit is contained in:
Bhushan Shah 2020-10-02 16:31:59 +05:30
parent 30a5cc766c
commit c9c05c3899
3 changed files with 14 additions and 26 deletions

View file

@ -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()

View file

@ -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)

View file

@ -9,6 +9,7 @@
#include <QObject>
#include <KWaylandServer/kwaylandserver_export.h>
#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