From ec8e78d5cc8a7d3c4d1929761bd80806b1d5e7c8 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 18 Mar 2024 00:09:32 +0100 Subject: [PATCH] refactor: Use Pointers.Modifiers.has less The performance characteristics of this function will change in future plans. --- srcs/juloo.keyboard2/KeyEventHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 6cc7171..de9fe8c 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -250,12 +250,11 @@ public final class KeyEventHandler implements Config.IKeyEventHandler if (conn == null) return; ExtractedText et = get_cursor_pos(conn); + int system_mods = + KeyEvent.META_CTRL_ON | KeyEvent.META_ALT_ON | KeyEvent.META_META_ON; // Fallback to sending key events - if (_move_cursor_force_fallback - || et == null - || _mods.has(KeyValue.Modifier.CTRL) - || _mods.has(KeyValue.Modifier.ALT) - || _mods.has(KeyValue.Modifier.META)) + if (_move_cursor_force_fallback || et == null + || (_meta_state & system_mods) != 0) { move_cursor_fallback(d); return; @@ -273,7 +272,7 @@ public final class KeyEventHandler implements Config.IKeyEventHandler { sel_end += d; // Leave 'sel_start' where it is if shift is pressed - if (!_mods.has(KeyValue.Modifier.SHIFT)) + if ((_meta_state & KeyEvent.META_SHIFT_ON) == 0) sel_start = sel_end; } if (!conn.setSelection(sel_start, sel_end))