Skip to content

Commit

Permalink
Ignore Ime::Enabled event on Linux
Browse files Browse the repository at this point in the history
It means different things on X11 and Wayland, and causes us to assume
IME is active when it isn't, causing the backspace and arrow keys to be
disabled.
  • Loading branch information
YgorSouza committed Sep 30, 2024
1 parent a72bdd7 commit db250de
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,13 @@ impl State {
// between Commits.
match ime {
winit::event::Ime::Enabled => {
self.ime_event_enable();
if cfg!(target_os = "linux") {
// This event means different things in X11 and Wayland, but we can just
// ignore it and enable IME on the preedit event.
// See <https://github.com/rust-windowing/winit/issues/2498>
} else {
self.ime_event_enable();
}
}
winit::event::Ime::Preedit(text, Some(_cursor)) => {
self.ime_event_enable();
Expand Down Expand Up @@ -502,9 +508,9 @@ impl State {

pub fn ime_event_enable(&mut self) {
if !self.has_sent_ime_enabled {
self.egui_input
.events
.push(egui::Event::Ime(egui::ImeEvent::Enabled));
// self.egui_input
// .events
// .push(egui::Event::Ime(egui::ImeEvent::Enabled));
self.has_sent_ime_enabled = true;
}
}
Expand Down

0 comments on commit db250de

Please sign in to comment.