Skip to content

Commit

Permalink
Clear preedit if there is no pending preedit on Wayland
Browse files Browse the repository at this point in the history
Fixes #2478.
  • Loading branch information
wengxt authored and kchibisov committed Sep 11, 2022
1 parent 2a2733b commit 156fa37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- On Windows, added `WindowExtWindows::set_undecorated_shadow` and `WindowBuilderExtWindows::with_undecorated_shadow` to draw the drop shadow behind a borderless window.
- On Windows, fixed default window features (ie snap, animations, shake, etc.) when decorations are disabled.
- On Windows, fixed ALT+Space shortcut to open window menu.
- On Wayland, fixed `Ime::Preedit` not being sent on IME reset.

# 0.27.2 (2022-8-12)

Expand Down
22 changes: 14 additions & 8 deletions src/platform_impl/linux/wayland/seat/text_input/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ pub(super) fn handle_text_input(
event_sink.push_window_event(WindowEvent::Ime(Ime::Commit(text)), window_id);
}

// Push preedit string we've got after latest commit.
if let Some(preedit) = inner.pending_preedit.take() {
let cursor_range = preedit
.cursor_begin
.map(|b| (b, preedit.cursor_end.unwrap_or(b)));
// Always send preedit on `Done` events.
let (text, range) = inner
.pending_preedit
.take()
.map(|preedit| {
let cursor_range = preedit
.cursor_begin
.map(|b| (b, preedit.cursor_end.unwrap_or(b)));

let event = Ime::Preedit(preedit.text, cursor_range);
event_sink.push_window_event(WindowEvent::Ime(event), window_id);
}
(preedit.text, cursor_range)
})
.unwrap_or_default();

let event = Ime::Preedit(text, range);
event_sink.push_window_event(WindowEvent::Ime(event), window_id);
}
_ => (),
}
Expand Down

0 comments on commit 156fa37

Please sign in to comment.