Capture Ctrl+Space shortcut in InputMethodService
Brief explanation: We have these stages - PWM interceptkeys - Appside pre IME stage - Appside IME stage - Appside onKeyEvent handling - PWM fallback Currently Ctrl+space is handled in PWM fallback. So, if app handles the key in onKeyEvent() then we never handle the shortcut. Some apps like browser are capturing all keys in onKeyEvent() for performance reasons or for scrolling. And this blocks the shortcut handling and makes it look flaky for the user. With the change: Ctrl+Space will take priority over app onKeyEvent capturing since it happens in Appside IME stage. This is only done when IME is visible i.e. user is actively typing. - User scenario#1: Ctrl+Space in browser while typing (i.e. IME is visible/active) -> language switch [This wasn't hapenning without the change] - User scenario#2: Ctrl+Space is browser while not in text field -> No language switch since browser captures it in onKeyEvent() stage. - User scenario#3: Ctrl+Space in apps that don't capture keyevents -> language switch due to PWM fallback This change is just fixing the User scenario #1 other things are still the same. But it seems that's the most important use case where we want to prioritize IME capturing the shortcut over app.Also, we still allow apps to block IME capturing the shortcut by overriding dispatchPreIme() which allos apps to capture key events in Pre Ime stage, allowing some apps like Minecraft, and other games that want full control on keys and has their own input handling for typing, etc. Test: atest InputMethodServiceTest Bug: 301969005 Change-Id: I2098ef61e1c2a4d53a46497a87a7840bf287ab92
Loading
Please register or sign in to comment