abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2025-07-06 23:18:58 +0200
committerGitHub2025-07-06 23:18:58 +0200
commit898956256a0d08884beb61c30e9f6881ea12740e (patch)
tree9873673793e0b32b2d6641b98c6e0bdb52b2ebe6
parent8cb9b3046110b17d93553edd8aedbae40748b2c5 (diff)
downloadunexpected-keyboard-898956256a0d08884beb61c30e9f6881ea12740e.tar.gz
unexpected-keyboard-898956256a0d08884beb61c30e9f6881ea12740e.zip
Workaround Godot editor not implementing setSelection() (#1033)
This was tested against: org.godotengine.editor.v3 org.godotengine.editor.v4
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 3c95f3d..33089d9 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -41,12 +41,7 @@ public final class KeyEventHandler
public void started(EditorInfo info)
{
_autocap.started(info, _recv.getCurrentInputConnection());
- // Workaround a bug in Acode, which answers to [getExtractedText] but do
- // not react to [setSelection] while returning [true].
- // Note: Using & to workaround a bug in Acode, which sets several
- // variations at once.
- _move_cursor_force_fallback = (info.inputType & InputType.TYPE_MASK_VARIATION &
- InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0;
+ _move_cursor_force_fallback = should_move_cursor_force_fallback(info);
}
/** Selection has been updated. */
@@ -473,6 +468,17 @@ public final class KeyEventHandler
return (conn.getSelectedText(0) != null);
}
+ /** Workaround some apps which answers to [getExtractedText] but do not react
+ to [setSelection] while returning [true]. */
+ boolean should_move_cursor_force_fallback(EditorInfo info)
+ {
+ // This catch Acode: which sets several variations at once.
+ if ((info.inputType & InputType.TYPE_MASK_VARIATION & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0)
+ return true;
+ // Godot editor: Doesn't handle setSelection() but returns true.
+ return info.packageName.startsWith("org.godotengine.editor");
+ }
+
public static interface IReceiver
{
public void handle_event_key(KeyValue.Event ev);