aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols
diff options
context:
space:
mode:
authorSungyoon Cho <[email protected]>2024-09-10 22:49:10 +0900
committerGitHub <[email protected]>2024-09-10 14:49:10 +0100
commit155d44016d0cb11332c454db73d59030cdbd7b13 (patch)
tree2227b41f972fea70108bf64046c2e012f637d848 /src/protocols
parent13f90bb87a697866f1bbbacd1473d04f33ec2aa7 (diff)
downloadHyprland-155d44016d0cb11332c454db73d59030cdbd7b13.tar.gz
Hyprland-155d44016d0cb11332c454db73d59030cdbd7b13.zip
textinput: handle IME resetting (#7731)
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/TextInputV1.cpp1
-rw-r--r--src/protocols/TextInputV1.hpp1
-rw-r--r--src/protocols/TextInputV3.cpp19
-rw-r--r--src/protocols/TextInputV3.hpp7
4 files changed, 22 insertions, 6 deletions
diff --git a/src/protocols/TextInputV1.cpp b/src/protocols/TextInputV1.cpp
index f25f5aca..dad74b53 100644
--- a/src/protocols/TextInputV1.cpp
+++ b/src/protocols/TextInputV1.cpp
@@ -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(
diff --git a/src/protocols/TextInputV1.hpp b/src/protocols/TextInputV1.hpp
index c85a1f31..9bee452c 100644
--- a/src/protocols/TextInputV1.hpp
+++ b/src/protocols/TextInputV1.hpp
@@ -37,6 +37,7 @@ class CTextInputV1 {
CSignal onCommit;
CSignal enable;
CSignal disable;
+ CSignal reset;
CSignal destroy;
} events;
diff --git a/src/protocols/TextInputV3.cpp b/src/protocols/TextInputV3.cpp
index 42dc659e..30374104 100644
--- a/src/protocols/TextInputV3.cpp
+++ b/src/protocols/TextInputV3.cpp
@@ -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() {
diff --git a/src/protocols/TextInputV3.hpp b/src/protocols/TextInputV3.hpp
index 9f6284dc..ba8b75e6 100644
--- a/src/protocols/TextInputV3.hpp
+++ b/src/protocols/TextInputV3.hpp
@@ -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;