Skip to content

Commit 879137a

Browse files
committed
Use CapabilityFlag to determine commitStringWithCursor availability
1 parent 6b23a73 commit 879137a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

app/src/main/cpp/androidkeyboard/androidkeyboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ void AndroidKeyboardEngine::commitBuffer(InputContext *inputContext) {
316316
if (preedit.empty()) {
317317
return;
318318
}
319-
if (auto icv2 = dynamic_cast<InputContextV2 *>(inputContext)) {
320-
icv2->commitStringWithCursor(preedit, cursor);
319+
if (inputContext->capabilityFlags().test(CapabilityFlag::CommitStringWithCursor)) {
320+
inputContext->commitStringWithCursor(preedit, cursor);
321321
} else {
322322
inputContext->commitString(preedit);
323323
}

app/src/main/java/org/fcitx/fcitx5/android/core/CapabilityFlag.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import splitties.bitflags.hasFlag
66

77
/**
88
* translated from
9-
* [fcitx-utils/capabilityflags.h](https://github.com/fcitx/fcitx5/blob/5.0.13/src/lib/fcitx-utils/capabilityflags.h)
9+
* [fcitx-utils/capabilityflags.h](https://github.com/fcitx/fcitx5/blob/5.1.1/src/lib/fcitx-utils/capabilityflags.h)
1010
*/
1111
@Suppress("unused")
1212
enum class CapabilityFlag(val flag: ULong) {
@@ -60,6 +60,17 @@ enum class CapabilityFlag(val flag: ULong) {
6060
*/
6161
ClientSideInputPanel(1UL shl 39),
6262

63+
/**
64+
* Whether client request input method to be disabled.
65+
* Usually this means only allow to type with raw keyboard.
66+
*/
67+
Disable(1UL shl 40),
68+
69+
/**
70+
* Whether client support commit string with cursor location.
71+
*/
72+
CommitStringWithCursor(1UL shl 41),
73+
6374
PasswordOrSensitive(Password.flag or Sensitive.flag);
6475

6576
}
@@ -75,7 +86,8 @@ value class CapabilityFlags constructor(val flags: ULong) {
7586

7687
val DefaultFlags = CapabilityFlags(
7788
CapabilityFlag.Preedit,
78-
CapabilityFlag.ClientUnfocusCommit
89+
CapabilityFlag.ClientUnfocusCommit,
90+
CapabilityFlag.CommitStringWithCursor
7991
)
8092

8193
fun fromEditorInfo(info: EditorInfo): CapabilityFlags {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy