diff options
| author | Jules Aguillon | 2024-03-18 01:00:22 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-03-18 01:00:22 +0100 |
| commit | e604f6fd57d85f46dd46da9da192646660547bc2 (patch) | |
| tree | 23e27096cc85ec85d865ef7f13afb6f7422b8c2c /srcs/juloo.keyboard2/Pointers.java | |
| parent | dc3a303af1ef72602b58292e5cc938944d6954ba (diff) | |
| download | unexpected-keyboard-e604f6fd57d85f46dd46da9da192646660547bc2.tar.gz unexpected-keyboard-e604f6fd57d85f46dd46da9da192646660547bc2.zip | |
refactor: Implement Compose without global state
Thanks to the previous commit, a modifier key can now be more complex
than just a KeyValue.Modifier. This allows a more elegant implementation
of the compose key, that could be taken as a base for other features
(eg. unicode hex entry, hangul)
The COMPOSE_PENDING modifier is removed as keys of kind Compose_pending
can act as a modifier. This has the advantage of highlighting the key
that was last pressed in the sequence.
Rules are added to Pointers: Non-special but latchable keys must clear
latches and cannot be locked with a long press. These rules were not
needed before but were intended.
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index f7efb9e..4a1c2d0 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -19,6 +19,10 @@ public final class Pointers implements Handler.Callback public static final int FLAG_P_LOCKABLE = (1 << 3); public static final int FLAG_P_LOCKED = (1 << 4); public static final int FLAG_P_SLIDING = (1 << 5); + /** Clear latched (only if also FLAG_P_LATCHABLE set). */ + public static final int FLAG_P_CLEAR_LATCHED = (1 << 6); + /** Can't be locked, even when long pressing. */ + public static final int FLAG_P_CANT_LOCK = (1 << 7); private Handler _keyrepeat_handler; private ArrayList<Pointer> _ptrs = new ArrayList<Pointer>(); @@ -153,6 +157,9 @@ public final class Pointers implements Handler.Callback } else if ((ptr.flags & FLAG_P_LATCHABLE) != 0) { + // Latchable but non-special keys must clear latched. + if ((ptr.flags & FLAG_P_CLEAR_LATCHED) != 0) + clearLatched(); ptr.flags |= FLAG_P_LATCHED; ptr.pointerId = -1; _handler.onPointerFlagsChanged(false); @@ -395,7 +402,8 @@ public final class Pointers implements Handler.Callback // Long press toggle lock on modifiers if ((ptr.flags & FLAG_P_LATCHABLE) != 0) { - lockPointer(ptr, true); + if (!ptr.hasFlagsAny(FLAG_P_CANT_LOCK)) + lockPointer(ptr, true); return false; } // Stop repeating: Latched key, no key @@ -452,7 +460,12 @@ public final class Pointers implements Handler.Callback { int flags = 0; if (kv.hasFlagsAny(KeyValue.FLAG_LATCH)) + { + // Non-special latchable key must clear modifiers and can't be locked + if (!kv.hasFlagsAny(KeyValue.FLAG_SPECIAL)) + flags |= FLAG_P_CLEAR_LATCHED | FLAG_P_CANT_LOCK; flags |= FLAG_P_LATCHABLE; + } if (kv.hasFlagsAny(KeyValue.FLAG_LOCK)) flags |= FLAG_P_LOCKABLE; return flags; |
