-
Notifications
You must be signed in to change notification settings - Fork 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
add composition event support #1404
add composition event support #1404
Conversation
This PR does not successfully build on any platform. You need to update your winit fork and rebase this branch against the current master. |
@murarth I know that. This failure is because we need to update x11-dl crate, as mentioned in the description. If you want to try to build in your local:
|
4c40f5b
to
67677b0
Compare
Now the new version of x11-dl is available. I updated my branch to use it.
|
This change requires x11-dl crate Also, I should send actual string in IME
After the discussion on the PR, I decided to follow the Web specification for the composition events. I added a few states to filter out unnecessary events.
706f1e8
to
29f0d7e
Compare
|
ptr::null_mut::<()>(), | ||
); | ||
println!("set preedit call 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.
Forgot to delete this?
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.
Removed
ffi::XNClientWindow_0.as_ptr() as *const _, | ||
window, | ||
ffi::XNPreeditAttributes_0.as_ptr() as *const _, | ||
pre_edit_attr.ptr, | ||
ptr::null_mut::<()>(), | ||
); | ||
println!("set preedit call back 2"); |
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.
And this?
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.
Removed
I think this PR is ready to merge (once those two I've created a new branch on winit so that we can merge this new API into |
.event_sender | ||
.send(( | ||
client_data.window, | ||
ImeEvent::Update(client_data.text.iter().collect(), client_data.cursor_pos), |
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.
The cursor position field here also needs to be converted to a byte offset, correct?
I didn't notice this in my previous review because I didn't see any erroneous events generated in my testing. When is the "caret" callback actually called?
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.
Fixed byte offset calculation.
This event will be called when you move your cusor in IME
The checks were failed, but the errors comes from where I didn't change
|
@murarth The CI tests were passed. Could you merge it? |
Thank you for your work on this implementation, @garasubo. A final note: I had named the new branch |
* WIP: add composition event suppor prototype This change requires x11-dl crate Also, I should send actual string in IME * send actual preedit string * run cargo fmt * update cargo.toml * remove warning * address comments in PR * follow web spec After the discussion on the PR, I decided to follow the Web specification for the composition events. I added a few states to filter out unnecessary events. * remove println * fix cursor pos calc * Re-run CI Co-authored-by: Murarth <murarth@gmail.com>
@@ -1188,6 +1197,40 @@ impl<T: 'static> EventProcessor<T> { | |||
} | |||
Err(_) => (), | |||
} | |||
match self.ime_event_receiver.try_recv() { |
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.
Hi @garasubo and @murarth , I'm implementing this for Mac, should I handle both WindowEvent::ReceivedCharacter
and CompositionEvent::End
at the same time, or just ignore WindowEvent::ReceivedCharacter
during composing?
I'm not sure how XIM work, but looks like here, in process_event
, both x event and ime event are handled?
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.
Thanks for get interested in this work. I don't have Mac dev environment, so that would be great.
I think we should handle both to keep compatibility, so in my implementation, both events are handled.
In XIM, IME events and receiving characters events are independent. So, I didn't touch any logic related to ReceivedCharacter event.
* WIP: add composition event suppor prototype This change requires x11-dl crate Also, I should send actual string in IME * send actual preedit string * run cargo fmt * update cargo.toml * remove warning * address comments in PR * follow web spec After the discussion on the PR, I decided to follow the Web specification for the composition events. I added a few states to filter out unnecessary events. * remove println * fix cursor pos calc * Re-run CI Co-authored-by: Murarth <murarth@gmail.com>
* WIP: add composition event suppor prototype This change requires x11-dl crate Also, I should send actual string in IME * send actual preedit string * run cargo fmt * update cargo.toml * remove warning * address comments in PR * follow web spec After the discussion on the PR, I decided to follow the Web specification for the composition events. I added a few states to filter out unnecessary events. * remove println * fix cursor pos calc * Re-run CI Co-authored-by: Murarth <murarth@gmail.com>
Fix #1293
Added new window events to get information about preedit status in IME:
CompositionStart
,CompositionUpdate
,CompositionEnd
.This change requires x11-dl crate. I've already send a pull request for it (AltF02/x11-rs#107)
TODO:
I'm not sure
ImeContextClientData
could be accessed at the same time. It might need to be wrapped withMutex
This feature only available in X11. I don't have other platform, so need to help implementing this feature for other platforms.
We also need to provide a way to disable this feature, since some people don't want to receive these new events.
Tested on all platforms changed
Compilation warnings were addressed
cargo fmt
has been run on this branchcargo doc
builds successfullyAdded an entry to
CHANGELOG.md
if knowledge of this change could be valuable to usersUpdated documentation to reflect any user-facing changes, including notes of platform-specific behavior
Created or updated an example program if it would help users understand this functionality
Updated feature matrix, if new features were added or implemented