abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyEventHandler.java
diff options
context:
space:
mode:
authorJules Aguillon2024-09-29 21:58:22 +0200
committerGitHub2024-09-29 21:58:22 +0200
commit9f22e53a3ba8f064e69e3a84c371a7f29ee9e05c (patch)
tree96735329102cdde5460818f22803e67dc42c6356 /srcs/juloo.keyboard2/KeyEventHandler.java
parente309b76c0a8cb4c322b5fa902a080e19c2fe1f08 (diff)
downloadunexpected-keyboard-9f22e53a3ba8f064e69e3a84c371a7f29ee9e05c.tar.gz
unexpected-keyboard-9f22e53a3ba8f064e69e3a84c371a7f29ee9e05c.zip
Add complex keys (#774)
This allows to add new kinds of keys that need more data without making KeyValue's footprint bigger for common keys. This changes the [_symbol] field into [_payload], which holds the same as the previous field for more common keys but can hold bigger objects for keys of the new "Complex" kind. This also adds a complex key: String keys with a symbol different than the outputted string. Unit tests are added as the Java language is not helpful in making robust code.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java')
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 087ac5b..c54ffa5 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -97,6 +97,7 @@ public final class KeyEventHandler
_recv.set_compose_pending(true);
break;
case Cursor_move: move_cursor(key.getCursorMove()); break;
+ case Complex: send_complex_key(key.getComplexKind(), key.getComplex()); break;
}
update_meta_state(old_mods);
}
@@ -215,6 +216,16 @@ public final class KeyEventHandler
conn.performContextMenuAction(id);
}
+ void send_complex_key(KeyValue.Complex.Kind kind, KeyValue.Complex val)
+ {
+ switch (kind)
+ {
+ case StringWithSymbol:
+ send_text(((KeyValue.Complex.StringWithSymbol)val).str);
+ break;
+ }
+ }
+
@SuppressLint("InlinedApi")
void handle_editing_key(KeyValue.Editing ev)
{