Skip to content

Forward GameActivity software keyboard text as Android IME events - #4837

Open
petralithic wants to merge 1 commit into
rust-windowing:masterfrom
petralithic:fix/android-gameactivity-ime-2026-11-12
Open

petralithic wants to merge 1 commit into
rust-windowing:masterfrom
petralithic:fix/android-gameactivity-ime-2026-11-12

Conversation

@petralithic

Copy link
Copy Markdown

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-core tests passed. ARM64 Android Clippy and
    rustdoc 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 changelog module if knowledge of this change could
    be 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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant