Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input method: don't forward key-release without correspinding key-press #2544

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tokyo4j
Copy link

@tokyo4j tokyo4j commented Dec 21, 2024

This PR follows the fix in labwc/labwc#2437.

After commit e2189903 in wlroots, when ctrl-f is pressed in firefox with a IME client running, the following key-release event for "f" is not sent, thus "f" is repeated like "ffffffffff..." in the input box of firefox.

The video below is the demonstration of the regression in labwc, but it also happens in wayfire:

2024-12-16.16-13-45.mp4

This happens in the following flow:

  • The compositor receives key-press events for ctrl+f and sends them to Firefox
  • Firefox enables text_input for the input box
  • The compositor activates the IME client
  • The compositor receives a key-release event for "f", and forward it to the IME client
  • The IME client sends the key-release event for "f" to the compositor via a virtual keyboard, but wlroots ignores it because the key "f" has not been pressed in the virtual keyboard.
  • As firefox doesn't see the key-release event, its repeat timer timeouts and it starts printing "fffffffff...".

So this PR fixes this problem by not forwarding the key-release event to the IME client unless the corresponding key-press event has also been forwarded.

@tokyo4j tokyo4j force-pushed the fix/firefox-fcitx5-key-repeat branch from 605a88e to 96f12f5 Compare December 21, 2024 17:27
@tokyo4j tokyo4j changed the title IME: don't forward key-release without correspinding key-press input method: don't forward key-release without correspinding key-press Dec 21, 2024
After commit e2189903 in wlroots, when ctrl-f is pressed in firefox with
a IME client running, the following key-release event for "f" is not
sent, thus "f" is repeated like "ffffffffff..." in the input box of
firefox. This is because the key-release event for "f" is firstly
forwarded to the IME client and then sent via the virtual keyboard created
by the IME client while the preceding key-press event is sent via physical
keyboard, and with e2189903, key-release events without a corresponding
key-press event on the same keyboard is not emitted to the compositor.

So this commit fixes this problem by not forwarding the key-release event
to the IME client unless the corresponding key-press event was also
forwarded.
@tokyo4j tokyo4j force-pushed the fix/firefox-fcitx5-key-repeat branch from 96f12f5 to cf283ca Compare February 23, 2025 10:31
@tokyo4j tokyo4j marked this pull request as draft February 23, 2025 10:34
@tokyo4j
Copy link
Author

tokyo4j commented Feb 23, 2025

Now I'm not confident that this PR should be merged because I noticed this PR causes another regression of stuck modifier in Firefox when pressing Ctrl+F (even though repeated fffffff... is fixed). Labwc had the same issue and I made a workaround for that, but it's a dirty workaround specifically for Fcitx5 and I honestly don't want to be responsible for applying that to Wayfire too.

Fortunately, wlroots devs agreed that the commit which caused the regression (repeated fffffff...) should be reverted in 0.18.3, and the issue that the commit tried to solve should be addressed in 0.19, with some API changes (https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4912#note_2715401).

So for now, I suggest keeping this PR on hold and waiting for wlroots 0.18.3 release.

@ammen99
Copy link
Member

ammen99 commented Feb 26, 2025

Now I'm not confident that this PR should be merged because I noticed this PR causes another regression of stuck modifier in Firefox when pressing Ctrl+F (even though repeated fffffff... is fixed). Labwc had the same issue and I made a workaround for that, but it's a dirty workaround specifically for Fcitx5 and I honestly don't want to be responsible for applying that to Wayfire too.

If you want to use fcitx5, I very strongly recommend using the input-method-v1 plugin instead of the support for input-method-v2 available in core. We had a lot of bugs and finally had to implement the older protocol, which turns out to be much more meaningful. Maybe try that and see whether the bug you're experiencing won't be fixed with that protocol.

I personally don't want to add any fcitx5-specific workarounds in core, as I think that the underlying problems are on the protocol level and using the older protocol is just a better option.

EDIT: I want to say this simply because even before all the wlroots changes you mention, fcitx5 + input-method-v2 was broken. We never got it to work properly in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants