-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement input method keyboard grab #4932
Conversation
There're two problems of handle_key patch in 7471b43, i've modified a patch.
As virtual_keyboard and real keyboard compose a keyboard_group, sway early return here. But we only use virtual_keyboard under grab, so it's essentially one keyboard. The workaround patch is attached at the end. EDIT: There are problems in swaywm/wlroots#1864 too. EDIT2: handle_modifier has similar problems on keyboard_group.
|
Not all release events are missing, right? According to my tests, release events are sent successfully at most cases. Sometime release events seems still somewhat missing like I uses Mod4 as my binding modifiers, but when I switches workspace, sometime Mod4 seems like get stuck and needs an extra press to solve it after this patch. I am still investigating this situation. The problems with keyboard grouping is explained at swaywm/wlroots#1864 (comment) |
My test IME will forward grab by virtual_keyboard immediately(i.e. just after receiving the key event).
Nope, all events are missing, with keyboard_group. I pressed the Now with And the imperfect part is that, when I started IME in a terminal, and press CTRL+C, I missed the release event of CTRL+C(IME is killed by SIGINT). So the corresponding release event was not forwarded by virtual_keyboard. The result is that, I saw lots of This could be a responsibility of clients, but it will be nice if sway handle it. EDIT: I am using musl-libc, with sway -d. |
Terminals kill the IME at the time it received press event, and when release event arrives, IME is already gone. Currently virtual-keyboard implementation does not send missing release event when it is gone. I think IME should handle SIGINT to be safe. |
Yep, if virtual-keyboard handle it, then we need some records at the side of wlroots. Sounds like what you say Whatever it is not a big problem compared to missing events. Both solutions are ok though. It is just, program could be killed by various signals, it's hard to handle all cases. Exceptions could kill IME too. Even IME handle this smoothly. If SIGKILL signal the program at similar time point, then program has no way to handle it at all. It is not asynchronously safe. |
7471b43
to
d18753d
Compare
d18753d
to
91551bb
Compare
I have just made virtual keyboard not to group when from same client as input method and also check and remove on grab start. It should make it work with keyboard grouping enabled but I think this can still be improved. |
91551bb
to
691da5a
Compare
Tested with wlhangul, seems to work fine. |
691da5a
to
b0558db
Compare
b0558db
to
a789c11
Compare
This PR needs a rebase. |
321f7f2
to
02c876d
Compare
Commit to ungroup virtual keyboard is dropped. It is not needed after #5204. |
02c876d
to
f77d7ca
Compare
f77d7ca
to
ed0398c
Compare
Is this still WIP? |
dc15b85
to
6bbf0ee
Compare
With input-method-unstable-v2, it's impossible to finish preedit texts before deactivate. I think this is a bug in IME. Focus changes deactivates the input-method and I think there is no way to know it is going to be deactivated in advance. Which means IME does not have chance to commit string to old text-input. Also, by the protocol, there is no way to distinguish the text-input behind. With these, I think IME should reset their internal states (for example, to-be-committed string) on deactivate. This is what my wlchewing does, and so it does not have this bug. @xdavidwu Reference: swaywm/sway#4932 (comment)
With input-method-unstable-v2, it's impossible to finish preedit texts before deactivate. I think this is a bug in IME. Focus changes deactivates the input-method and I think there is no way to know it is going to be deactivated in advance. Which means IME does not have chance to commit string to old text-input. Also, by the protocol, there is no way to distinguish the text-input behind. With these, I think IME should reset their internal states (for example, to-be-committed string) on deactivate. This is what my wlchewing does, and so it does not have this bug. @xdavidwu Reference: swaywm/sway#4932 (comment)
Thank you! I could workaround the "Focus change bug" and fix the "Key repeat bug". This PR is currently being thoroughly tested by bunch of Korean sway users and now we're all experiencing no more bugs! Is there any left blocker before merging this PR? Looks like the keymap spamming issue has been fixed with latest commit since it doesn't occur anymore! |
Key repeat of bypassed key shouldn't be handled by IME. Reference: swaywm/sway#4932 (comment)
Key repeat of bypassed key shouldn't be handled by IME. Reference: swaywm/sway#4932 (comment)
Key repeat of bypassed key shouldn't be handled by IME. Reference: swaywm/sway#4932 (comment)
I'm maintain new Korean IME kime and I met several repeat bugs of course it's IME bug but problem is its repeat was triggered in client side which is unexpected behavior for me Why client get |
Yeah I think this patch itself is enough tested and reviewed by bunch of people who desperately want to use IME with sway. :) |
cd053e1
to
9755086
Compare
I've seen the patched AUR package with this added. How is this actually configured and used? Please and thanks :) |
Just install patched version of sway and turn on the IME which have input-method-unstable-v2 supports like kime, fcitx5. Then it automatically works. For Arch Linux with kime:
Reference |
I did manage to get |
This is because some applications also support IME input without going through the window system, using (for example) D-Bus instead of X11 or Wayland. Alacritty only supports X11 (xim) and Wayland (text-input-v3) IMEs directly, as far as I know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been trying to review this for quite some time. I'm really sorry for the huge delay, once again.
Overall the logic looks correct to me.
I have trouble with the changes in handle_key_event
. This function is already a little bit tricky to follow, and the changes introduce more complexity (duplicated wlr_seat_keyboard_notify_key
, goto end
). I've left some comments to see if we can improve that a bit.
In other news, we're trying to revive the IM standardization efforts in the wayland-protocols repo. If you have feedback about text-input or input-method, please feel free to leave a comment:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/39
9755086
to
e397ebc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks a lot!
This implements input-method-unstable-v2 keyboard grab.
Depends on:
#4740,swaywm/wlroots#1864