Repository navigation
android: report GameTextInput edits as IME events - #4736
Open
SergioRibera wants to merge 1 commit into
Open
SergioRibera wants to merge 1 commit into
SergioRibera wants to merge 1 commit into
Conversation
SergioRibera
force-pushed
the
android-ime-events-pr
branch
from
October 26, 2026 19:53
1feb8d2 to
32af5e4
Compare
This branch has not been deployed
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.
With the
game-activitybackend, text typed on the soft keyboard reaches winit asInputEvent::TextEvent, a snapshot of the wholeGameTextInputbuffer (text, selection and composing region). The backend currently drops it withUnknown android_activity input event, so typing only works for the few keys an IME sends as key events. On top of that the keyboard never learns what the field contains, so it can't capitalize or suggest from it.This turns those snapshots into the
Imeevents other backends send:GameTextInputreports its whole buffer, winit reports edits relative to the selection, so the newime.rskeeps the field as the application has been told about it and diffs every snapshot against it. The changed span between the common prefix and suffix is widened to the selection, then reported asIme::DeleteSurrounding+Ime::Commit(the commit replaces the selection, like on Wayland).Ime::Preedit, with the caret inside it when the selection is in it. Keyboards that re-compose the word behind the caret (Gboard does it when you backspace into a word) show up as a deletion followed by a preedit, which is what the application needs to keep the same text on screen.Ime::Enabled/Ime::Disabledare reported when the IME is enabled or disabled.ImeSurroundingTextfromImeRequest::Enable/Updateis loaded intoGameTextInput.GameTextInputrestarts the input connection every time its buffer is replaced, and the keyboard then forgets the word it is composing, its shift state, etc. So nothing is loaded when the buffer already holds that text, which is the common case of an application echoing back an edit the keyboard just made. When something is loaded while composing, the preedit is kept in the buffer as the composing region.ImeRequest::Disable, so the next field doesn't start with the text of the previous one.Known limitations, all on the
GameTextInputside:requestCursorUpdatesisn't implemented there, so there's noCursorAnchorInfoandset_ime_cursor_areastays a no-op.InputMethodManager.updateSelection.Caret moves made by the keyboard itself (space bar drag) aren't reported yet, that needs a new event and is a separate PR.
Probably closes #4067
screenrecorder-20261005-151422.mp4
screenrecorder-20261005-154155.mp4
changelogmodule if knowledge of this change could be valuable to users