-
Notifications
You must be signed in to change notification settings - Fork 340
Conversation
This looks like a great start. Can you rebase it against master? Whether or not to extend examples/input-method.c or write a new example is at your discretion. |
fadbcb5
to
4f9d374
Compare
9dd7ddb
to
27a923b
Compare
Is there a particular IME software you're looking to implement this for? ibus? |
I plan to implement a new IME with libchewing, not using existing frameworks like ibus or fcitx. |
Oh, nice. Hoping for anthy support too 😄 |
27a923b
to
8b6668d
Compare
I found that |
You should intercept those events, I think. Virtual keyboards behave just like any other kind. |
Then I think there is no way for a input method to send unhandled key events back to the surface. Should we add an interface to input-method protocol for this? |
I'm not sure I fully understand the problem. Can you explain it in more detail? |
I have been writing a experimental input-method client that grabs, and I found that I need to send key events that are not handled by input-method back to the application for things like moving the cursor to already committed text or some keyboard shortcuts like ctrl+s. If I use virtual-keyboard for that, the events would be caught by the input-method again. |
Is the key forwarding request in input-method not sufficient? |
There is only event that send key to input method, but no request method to send it back (when unhandled) to the surface that requested text input. |
Oh I didn't know that v1 has it. In input-method-unstable-v2 bundled in protocols/ it is missing. |
Ah, I see. I think we did split that off, now that you mention it. Let's say that virtual keyboards should bypass input-method, then. Virtual keyboards which want to do i18n input should probably use input-method themselves, I think that was the idea. |
d0aa634
to
7014de1
Compare
efd3637
to
13bd079
Compare
13bd079
to
4d78aad
Compare
4d78aad
to
3a15126
Compare
@xdavidwu Good work. I am trying to modify wlchewing, or almost rewrite a new one based libpinyin probably. But I found a bug with the current implementation. The workaround patch first:
I am not familiar with the internal mechanics of wlroots, I can not tell the full picture. But, this is basically what happened: I have a native keyboard, and a virtual keyboard. So sway is using keyboard_group to multiplex events. Thus, what we grab is the fake wlr_keyboard in keybaord_group object. But that fake wlr_keyboard was not with virtual_keyboard pointer. So your sway grab code will not work at all. BTW: I do not think the current implementation is "good" enough.
EDIT: I can confirm that grab interface and ime interface are working in a pure wayland environment(no x11/GLX at all). I can type things in a patched pure-wayland(cairo-gtk3-wayland) firefox. I will continue my work this minimal IME and exam popup interface. Because I really can not find a working native IME. |
wlr_keyboard_group is a helper to reduce keyboard events. For example, assuming there is a keyboard group g1 consisting of two keyboards k1 and k2, and the original events sequence look like this: (with the same key) k1 pressed, k2 pressed, k1 released, k2 released. Keyboards with same keymap can be grouped. In keyboard grab + virtual keyboard combo, both virtual and the original keyboard device will likely have the same keymap and currently will be grouped. But the events here should not be reduced. In the above example, replace k1 with original keyboard and k2 with virtual keyboard, k1 should be sent to input-method grab and k2 should be sent to text-input client. I think the ideal solution is not to group the virtual one when it is a keyboard grab + virtual keyboard combo. I will find a way to do this. A temporarily workaround would be turn off grouping in sway config, by
Nice catch, I will fix it soon. I implemented the grab in wlroots initially but decided to move it to sway to make use of pressed event sent state tracking to avoid cut off a press-release pair. Edit: I recalled it incorrectly about how keymaps are sent in my code. It is by a new function I wrote. I will update it to avoid sending identical keymaps soon. |
3a15126
to
17c1192
Compare
return; | ||
} | ||
if (input_method->im_keyboard_grab) { | ||
// Already grabbed |
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.
Should we send a protocol error here? If it's missing, we should add it to the protocol.
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.
Overall looks good.
The interactions between IME keyboard grabs and other grabs are complicated. I'll think a bit more about this.
Is this ready for another review round? |
That means a VNC session will bypass the input-method, too. I wonder if that's desirable. |
I've make only virtual keyboard from the same client as grab bypass input-method grab on sway side. |
This isn't going to work in all cases. For instance a user using Waypipe would have all Wayland objects belonging to the same client. On the long run I think we'll want to add a way for clients to tie a virtual-keyboard to an input-method. |
With these remaining comments fixed, this LGTM! |
Created a follow-up issue: #2322 |
I've squashed all of your commits into three logical commits. Also made a minor change to avoid breaking the API: added back |
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.
Code LGTM. Thanks for working on this!
I'm interested in implementing CJK input method in wayland so I try to implement this.
I've tested with my local client code but it's not suitable for a test example.
Should I extend examples/input-method.c for this or write a new one