wayland: Clear preedit if there is no pending preedit.#2481
Merged
kchibisov merged 1 commit intorust-windowing:masterfrom Sep 9, 2022
wengxt:master
Merged
wayland: Clear preedit if there is no pending preedit.#2481kchibisov merged 1 commit intorust-windowing:masterfrom wengxt:master
kchibisov merged 1 commit intorust-windowing:masterfrom
wengxt:master
Conversation
kchibisov
requested changes
Sep 8, 2022
Member
There was a problem hiding this comment.
Thanks. Could you apply this, so we don't spend time reformatting it.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e648fd5..9c39fcf4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- On Wayland, a new `wayland-csd-adwaita-crossfont` feature was added to use `crossfont` instead of `ab_glyph` for decorations.
- On Wayland, if not otherwise specified use upstream automatic CSD theme selection.
- 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)
diff --git a/src/platform_impl/linux/wayland/seat/text_input/handlers.rs b/src/platform_impl/linux/wayland/seat/text_input/handlers.rs
index 8f05bb60..f4f131d0 100644
--- a/src/platform_impl/linux/wayland/seat/text_input/handlers.rs
+++ b/src/platform_impl/linux/wayland/seat/text_input/handlers.rs
@@ -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);
}
_ => (),
}
I think that should still work.
Member
|
Actually, I think I'd adjust all platforms to send empty preedit before the |
Contributor
Author
|
applied, thanks. I
applied |
kchibisov
approved these changes
Sep 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #2478
CHANGELOG.mdif knowledge of this change could be valuable to users