Re-enable IME support on Linux (#5198)
Reverts #5188 and adds a different fix to restore IME on Linux without breaking the backspace and arrow keys. * Closes https://github.com/emilk/egui/issues/5544 * Closes https://github.com/emilk/egui/pull/5198 * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
e32ca218e8
commit
3ffe1ed774
|
|
@ -333,43 +333,45 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowEvent::Ime(ime) => {
|
WindowEvent::Ime(ime) => {
|
||||||
if cfg!(target_os = "linux") {
|
// on Mac even Cmd-C is pressed during ime, a `c` is pushed to Preedit.
|
||||||
// We ignore IME events on linux, because of https://github.com/emilk/egui/issues/5008
|
// So no need to check is_mac_cmd.
|
||||||
} else {
|
//
|
||||||
// on Mac even Cmd-C is pressed during ime, a `c` is pushed to Preedit.
|
// How winit produce `Ime::Enabled` and `Ime::Disabled` differs in MacOS
|
||||||
// So no need to check is_mac_cmd.
|
// and Windows.
|
||||||
//
|
//
|
||||||
// How winit produce `Ime::Enabled` and `Ime::Disabled` differs in MacOS
|
// - On Windows, before and after each Commit will produce an Enable/Disabled
|
||||||
// and Windows.
|
// event.
|
||||||
//
|
// - On MacOS, only when user explicit enable/disable ime. No Disabled
|
||||||
// - On Windows, before and after each Commit will produce an Enable/Disabled
|
// after Commit.
|
||||||
// event.
|
//
|
||||||
// - On MacOS, only when user explicit enable/disable ime. No Disabled
|
// We use input_method_editor_started to manually insert CompositionStart
|
||||||
// after Commit.
|
// between Commits.
|
||||||
//
|
match ime {
|
||||||
// We use input_method_editor_started to manually insert CompositionStart
|
winit::event::Ime::Enabled => {
|
||||||
// between Commits.
|
if cfg!(target_os = "linux") {
|
||||||
match ime {
|
// This event means different things in X11 and Wayland, but we can just
|
||||||
winit::event::Ime::Enabled => {
|
// ignore it and enable IME on the preedit event.
|
||||||
|
// See <https://github.com/rust-windowing/winit/issues/2498>
|
||||||
|
} else {
|
||||||
self.ime_event_enable();
|
self.ime_event_enable();
|
||||||
}
|
}
|
||||||
winit::event::Ime::Preedit(text, Some(_cursor)) => {
|
}
|
||||||
self.ime_event_enable();
|
winit::event::Ime::Preedit(text, Some(_cursor)) => {
|
||||||
self.egui_input
|
self.ime_event_enable();
|
||||||
.events
|
self.egui_input
|
||||||
.push(egui::Event::Ime(egui::ImeEvent::Preedit(text.clone())));
|
.events
|
||||||
}
|
.push(egui::Event::Ime(egui::ImeEvent::Preedit(text.clone())));
|
||||||
winit::event::Ime::Commit(text) => {
|
}
|
||||||
self.egui_input
|
winit::event::Ime::Commit(text) => {
|
||||||
.events
|
self.egui_input
|
||||||
.push(egui::Event::Ime(egui::ImeEvent::Commit(text.clone())));
|
.events
|
||||||
self.ime_event_disable();
|
.push(egui::Event::Ime(egui::ImeEvent::Commit(text.clone())));
|
||||||
}
|
self.ime_event_disable();
|
||||||
winit::event::Ime::Disabled | winit::event::Ime::Preedit(_, None) => {
|
}
|
||||||
self.ime_event_disable();
|
winit::event::Ime::Disabled | winit::event::Ime::Preedit(_, None) => {
|
||||||
}
|
self.ime_event_disable();
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
EventResponse {
|
EventResponse {
|
||||||
repaint: true,
|
repaint: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue