textinput: handle IME resetting (#7731)

This commit is contained in:
Sungyoon Cho
2024-09-10 22:49:10 +09:00
committed by GitHub
parent 13f90bb87a
commit 155d44016d
8 changed files with 49 additions and 19 deletions

View File

@@ -31,6 +31,7 @@ CTextInputV1::CTextInputV1(SP<CZwpTextInputV1> resource_) : resource(resource_)
resource->setReset([this](CZwpTextInputV1* pMgr) {
pendingSurrounding.isPending = false;
pendingContentType.isPending = false;
events.reset.emit();
});
resource->setSetSurroundingText(

View File

@@ -37,6 +37,7 @@ class CTextInputV1 {
CSignal onCommit;
CSignal enable;
CSignal disable;
CSignal reset;
CSignal destroy;
} events;

View File

@@ -19,17 +19,22 @@ CTextInputV3::CTextInputV3(SP<CZwpTextInputV3> resource_) : resource(resource_)
resource->setOnDestroy([this](CZwpTextInputV3* r) { PROTO::textInputV3->destroyTextInput(this); });
resource->setCommit([this](CZwpTextInputV3* r) {
bool wasEnabled = current.enabled;
bool wasEnabled = current.enabled.value;
current = pending;
serial++;
if (wasEnabled && !current.enabled)
if (wasEnabled && !current.enabled.value)
events.disable.emit();
else if (!wasEnabled && current.enabled)
else if (!wasEnabled && current.enabled.value)
events.enable.emit();
else if (current.enabled.value && current.enabled.isEnablePending && current.enabled.isDisablePending)
events.reset.emit();
else
events.onCommit.emit();
pending.enabled.isEnablePending = false;
pending.enabled.isDisablePending = false;
});
resource->setSetSurroundingText([this](CZwpTextInputV3* r, const char* text, int32_t cursor, int32_t anchor) {
@@ -54,10 +59,14 @@ CTextInputV3::CTextInputV3(SP<CZwpTextInputV3> resource_) : resource(resource_)
resource->setEnable([this](CZwpTextInputV3* r) {
pending.reset();
pending.enabled = true;
pending.enabled.value = true;
pending.enabled.isEnablePending = true;
});
resource->setDisable([this](CZwpTextInputV3* r) { pending.enabled = false; });
resource->setDisable([this](CZwpTextInputV3* r) {
pending.enabled.value = false;
pending.enabled.isDisablePending = true;
});
}
CTextInputV3::~CTextInputV3() {

View File

@@ -31,6 +31,7 @@ class CTextInputV3 {
CSignal onCommit;
CSignal enable;
CSignal disable;
CSignal reset;
CSignal destroy;
} events;
@@ -53,7 +54,11 @@ class CTextInputV3 {
CBox cursorBox;
} box;
bool enabled = false;
struct {
bool isEnablePending = false;
bool isDisablePending = false;
bool value = false;
} enabled;
zwpTextInputV3ChangeCause cause = ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD;