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

Inform downstream about IME state #1452

Closed
chrisduerr opened this issue Feb 10, 2020 · 10 comments
Closed

Inform downstream about IME state #1452

chrisduerr opened this issue Feb 10, 2020 · 10 comments
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos

Comments

@chrisduerr
Copy link
Contributor

This was reported in Alacritty in alacritty/alacritty#1606.

It seems like when the IME interface is open, winit intercepts all ReceivedCharacter events and instead forwards them to the IME. This works well for applications that rely solely on winit's ReceivedCharacter event to insert text, but it creates problems when characters are inserted as a result of other keyboard events.

There are several solutions for this, winit could for example not send any keyboard events when the IME is open and instead pretend it is a completely separate window. Alternatively, just informing the application about the current IME state would allow at least conditionally disabling keyboard handling when the interface is open.

@garasubo
Copy link
Contributor

garasubo commented Apr 3, 2020

@chrisduerr I implemented IME events interfaces in #1293. It is not merged master because it is implemented only for x11 environment (#1497 is the tracking issue for other platform), but could this be the solution for it?

@chrisduerr
Copy link
Contributor Author

It seems like that might make it possible to fix it, yes.

Though I do have to say that the naming of these events is extremely unfortunate.

@garasubo
Copy link
Contributor

garasubo commented Apr 4, 2020

Though I do have to say that the naming of these events is extremely unfortunate.

I don't have a strong preference about naming, but do you have any other ideas about naming? These naming come from web API (https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
But since these events are not merged to master, so I think we can discuss the details and change them.
I'm a just contributor, but feel free to comment on #1497 if you have any concerns related to IME events.

@chrisduerr
Copy link
Contributor Author

These naming come from web API

That's probably not the best guideline for a toolkit where large parts are completely unrelated to the web. Of course taking inspiration from other APIs is always good, but I don't think it's the best choice here.

I've left a suggestion on #1497.

@kchibisov
Copy link
Member

Also, if we're going to inform downstream about various IME states, I feel like we should add helpers like setting surrounding text around the cursor, content type, etc. The surround text should inform about cursor position, etc.

@garasubo since you've been doing some work wrt input method in winit, what do you think about exposing more methods?

For Wayland I'd need stuff from https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/master/unstable/text-input/text-input-unstable-v3.xml . I'm not sure how it maps to whatever X11 has, but I guess everything should have a concept of surrounding text and cursor position?

In general, since winit is lacking IME support for a lot of platforms, except macOS/X11 (Wayland will be added very soon). I feel like we can accelerate addition of such things, since those are essential for inline IME edditing, at least surrounding.

@garasubo
Copy link
Contributor

@kchibisov Good point. In my current implmentation, we can get the cursor position, but I didn't consider the surrounding text in IME. I'm not sure we can get the related information from X11.

@kchibisov
Copy link
Member

I'm not sure we can get the related information from X11.

I mean, not get but rather set. On Wayland you can tell IME that you have some text around you, so it can suggest things accounting for that. Wayland doesn't know about surrounding text either unless you tell it.

@garasubo
Copy link
Contributor

@kchibisov Oh, you meant preedit string in IME? Then, get is already implemented. For set, I haven't implmented, but looks like we can, according to https://github.com/glfw/glfw/pull/658/files

@kchibisov
Copy link
Member

I’m mostly talking about set things on a winit window, so user can implement cursor motions inside preedit string.

@kchibisov
Copy link
Member

This long done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos
Development

No branches or pull requests

4 participants