-
Notifications
You must be signed in to change notification settings - Fork 941
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 on macOS #1979
Conversation
hmm.... |
I think we might need to update our Android and WASM CI, so you don't need to do anything yourself (unless you'd like to fix our CI for us :D). |
Is it possible for you to provide a minimal example, so that we can reproduce without having to build Alacritty? Additionally, maybe you could also provide an explanation of why this is necessary / why it works, because that is not immediately obvious to me 😉 |
Thank you for fixing CI ! And sorry for less explanation. It seems Winit has backend and frontend. Backend for each OS corresponds to So far, in macOS, keyboard event didn't work fine for Japanese language. This is a topic of linguistics. Let's get back to a topic of IME API. In this PR, I implemented this architecture by adding event-push part to Thank you for reading long description. Ref: |
I'm sorry I don't have a minimal example for this. |
Correct me if I'm wrong but it seems that this implementation does the following:
I have to admit, this is a kinda smart way of dealing with IME without changing winit's API. I would actually be willing to merge this, considering that the discussion at #1497 got stuck almost a year ago. We can add a nice IME API later. With that said, I haven't tested this PR so I'm going to give a proper review later, I think, but in the meantime @madsmtm feel free to review this. |
Here's a small test application: Click for the codeuse log::LevelFilter;
use simple_logger::SimpleLogger;
use winit::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
fn main() {
SimpleLogger::new().with_level(LevelFilter::Debug).init().unwrap();
let event_loop = EventLoop::new();
let _window = WindowBuilder::new()
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(&event_loop)
.unwrap();
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => *control_flow = ControlFlow::Exit,
Event::WindowEvent {
event: WindowEvent::ReceivedCharacter(ch),
..
} => {
println!("recv ch: {:?}", ch);
}
_ => (),
}
});
} |
@ArturKovacs Thank you for reviewing ! I fixed parts you pointed out. Can you check again ? |
src/platform_impl/macos/view.rs
Outdated
); | ||
let composed_string = str::from_utf8_unchecked(slice); | ||
|
||
state.marked_text = composed_string.to_string(); |
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.
Now there's a state.marked_text
as well as a markedText
field. They seem to store the same text. I have a specific idea of resolving this. Would you mind if I added changes to this PR?
If you would not like me to add commits to this PR, that's completely okay, but then please remove either state.marked_text
or markedText
. Preferrably we would only have the NSMutableAttributedString
stored within the ViewState
.
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.
Welcome your patch !
I'm also confused there are duplicated information for markedText
and state.marked_text
.
markedText
is referred in setMarkedText
but I'm not sure how to remove this because I'm not familiar with Obj-c and type system between Obj-c and Rust.
I appreciate your help.
It should be fine, but please test as thoroughly as you can, because I may have broken something. |
This works fine and looks really simple ! |
#1669 is duplicated against this PR. |
Oh no. I forgot about the changelog. Maybe I'll make another PR just for updating the changelog |
Sure! When I tackle this issue, I refered your implementation for X11 and Wayland. I'd like to return the favor. I'll also try. |
This reverts commit 8afeb91. Reverting because this change made pinyin input unusable (only latin characters showed even after selecting the desired Chinese character)
This reverts commit 8afeb91. Reverting because this change made pinyin input unusable (only latin characters showed even after selecting the desired Chinese character)
This reverts commit 8afeb91. Reverting because this change made pinyin input unusable (only latin characters showed even after selecting the desired Chinese character)
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to usersThis change is to enable to use IME.
Before:
default.mov
After:
default.mov