Bug 492225 - text-input-v3: kwin does not send empty preedit when backspace is pressed after composing one character.
Summary: text-input-v3: kwin does not send empty preedit when backspace is pressed aft...
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: 6.2.4
Platform: Arch Linux Linux
: HI normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-26 16:55 UTC by orko
Modified: 2024-12-16 18:32 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description orko 2024-08-26 16:55:44 UTC
SUMMARY
text-input-v3: kwin does not send empty or null preedit when backspace is pressed after a single character is composed.

STEPS TO REPRODUCE
1. With WAYLAND_DEBUG=1 and filtering for text-input-v3 logs, open any app that uses text-input-v3 and focus an input field
2. Switch language to enable IME (e.g. japanese anthy)
3. Enter a character, e.g. 'a'
4. Press backspace

OBSERVED RESULT
3. The preedit string is received:
```
zwp_text_input_v3#44.preedit_string("あ", 3, 3)
zwp_text_input_v3#44.done(31)
```

4. Only `done` is received:
```
zwp_text_input_v3#44.done(31)
```

EXPECTED RESULT

3. Should be same as seen

4. Another `preedit` and `done` should be received:
```
zwp_text_input_v3#44.preedit_string("", 0, 0)
zwp_text_input_v3#44.done(31)
```

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version:  6.1.4

ADDITIONAL INFORMATION
When backspace is pressed after two characters are entered, it correctly sends the new preedit with the single character.

In text-input-v1 it does send an empty preedit string when backspace is entered.
```
zwp_text_input_v1#44.preedit_string(0, "", "")
```

Also, gnome sends a nil preedit string in text-input-v3 as well:
```
zwp_text_input_v3#40.preedit_string(nil, 0, 0)
zwp_text_input_v3#40.done(514)
```
Comment 1 David Edmundson 2024-09-23 11:27:34 UTC
You are right that kwin does this.

Though note that from the documentation:

>Values set with this event are double-buffered. 
>They must be applied and reset to initial on the next zwp_text_input_v3.done event.
>The initial value of text is an empty string, and cursor_begin, cursor_end and cursor_hidden are all 0.

We sent the done after the あ character, when we send done again, the client should be applying "", 0, 0 anyway.

I think this makes it a client bug.
Comment 2 Bug Janitor Service 2024-09-23 12:35:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6470
Comment 3 David Edmundson 2024-09-23 12:38:03 UTC
I made a pending patch, then we have options available if I'm talking nonsense or if a released Chrome relies on this behaviour.
Comment 4 orko 2024-09-23 15:17:47 UTC
@David Thanks for looking into this.

> They must be applied and reset to initial on the next zwp_text_input_v3.done event

This is true. However, I was not sure when that is applicable, because the following doc from zwp_text_input_v3.done seems somewhat contradictory:

> Instruct the application to apply changes to state requested by the preedit_string, commit_string and delete_surrounding_text events

So it was my interpretation that if there are no state changes explicitly requested by those events, there are no changes to be applied.
I could be interpreting it wrong still, or perhaps there could be some further clarification in the protocol.

> if a released Chrome relies on this behaviour

Technically chrome does have an "experimental" option to enable text-input-v3 which does rely on this behavior, but it's still not an officially supported feature yet, and probably won't be until the key events are supported. However, users might be running into this until then. So I'm open to it being addressed in either chrome or KDE.
Comment 5 Bug Janitor Service 2024-10-08 03:47:24 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2024-10-23 03:47:16 UTC
🐛🧹 This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.
Comment 7 ilovecreeper372 2024-12-14 11:23:45 UTC
Any updates on this? It looks like Chromium want to fix it on their end but no progress since.

https://issues.chromium.org/issues/40113488#comment128
Comment 8 TraceyC 2024-12-16 18:32:03 UTC
There is a draft merge request with a patch for this, which is awaiting review. The link is in this bug report.