Repository navigation
Forward GameActivity software keyboard text as Android IME events - #4837
Open
petralithic wants to merge 1 commit into
Open
petralithic wants to merge 1 commit into
petralithic wants to merge 1 commit into
Conversation
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.
Why this is needed
An Android software keyboard can compose and commit text through GameActivity
without an ordinary key event. Winit's Android loop currently drops the
resulting text-state update. Apps using GameActivity can therefore lose both
provisional and committed text when typing with a Japanese IME.
Change
Handle GameActivity text snapshots and emit Winit IME preedit, commit, and
surrounding-deletion events. Convert Java UTF-16 offsets to UTF-8 byte
positions. Track the committed portion of the current GameActivity buffer so
the next commit does not repeat earlier text.
This covers edits represented by GameActivity's text snapshots. Synchronizing
arbitrary application-side selection or surrounding-text changes is a separate
step. Related work on the 0.30 branch is #4451.
Verification
Android 16 API 36 ARM64 emulator, GameActivity 4.4.0 and android-activity 0.6.1.
A test keyboard used Android's real input connection to compose
東京 🦀,revise it to
東京 🦀?, commit東京 🦀, append!, and delete🦀!.Winit reported both preedits with byte-based caret positions, exactly two
commits, and a five-byte surrounding deletion. Before the patch, GameActivity
received the composing and committed text and Winit emitted neither event.
Nightly formatting and
winit-coretests passed. ARM64 Android Clippy andrustdoc passed with GameActivity and NativeActivity. The NativeActivity
build and test builds for both activity features passed.
Tested on all platforms changed
Added an entry to the
changelogmodule if knowledge of this change couldbe valuable to users
Documented the GameActivity behavior and scope in the changelog and above
Created or updated an example program if it would help users understand
this functionality