diff options
author | Vaxry <[email protected]> | 2024-05-09 14:27:48 +0100 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-05-09 14:27:48 +0100 |
commit | d7aed240db408259228bf09708986c82bdca23eb (patch) | |
tree | 2f0f78bb34d9caa282c5e60a45008bad22daf3eb | |
parent | c98acaed62db806c41b7d1b5ad63a89f18bce70a (diff) | |
download | Hyprland-d7aed240db408259228bf09708986c82bdca23eb.tar.gz Hyprland-d7aed240db408259228bf09708986c82bdca23eb.zip |
text-input-v3: atomically enable/disable on commit
-rw-r--r-- | src/protocols/TextInputV3.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/protocols/TextInputV3.cpp b/src/protocols/TextInputV3.cpp index 233f5209..b463c6d6 100644 --- a/src/protocols/TextInputV3.cpp +++ b/src/protocols/TextInputV3.cpp @@ -8,7 +8,6 @@ void CTextInputV3::SState::reset() { surrounding.updated = false; contentType.updated = false; box.updated = false; - enabled = false; } CTextInputV3::CTextInputV3(SP<CZwpTextInputV3> resource_) : resource(resource_) { @@ -21,9 +20,18 @@ 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; + current = pending; - events.onCommit.emit(); serial++; + + if (wasEnabled && !current.enabled) { + current.reset(); + events.disable.emit(); + } else if (!wasEnabled && current.enabled) + events.enable.emit(); + else + events.onCommit.emit(); }); resource->setSetSurroundingText([this](CZwpTextInputV3* r, const char* text, int32_t cursor, int32_t anchor) { @@ -46,13 +54,9 @@ CTextInputV3::CTextInputV3(SP<CZwpTextInputV3> resource_) : resource(resource_) pending.box.cursorBox = {x, y, w, h}; }); - resource->setEnable([this](CZwpTextInputV3* r) { - events.enable.emit(); - pending.enabled = true; - }); + resource->setEnable([this](CZwpTextInputV3* r) { pending.enabled = true; }); resource->setDisable([this](CZwpTextInputV3* r) { - events.disable.emit(); pending.enabled = false; pending.reset(); }); |