From c7ed2bcae915886b9d35bd19934f40816ef86b81 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 2 May 2024 11:58:44 +0200 Subject: [PATCH] Clear cache when changing layout Due to the modmap, the cache must be cleared when switching layout to or from a layout that contain a modmap. This is broken since 3f6b6fd23, which moves the modmap handling into KeyModifier. --- srcs/juloo.keyboard2/KeyModifier.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 377f54f..79531b2 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -13,7 +13,14 @@ public final class KeyModifier /** The optional modmap takes priority over modifiers usual behaviors. Set to [null] to disable. */ private static KeyboardData.Modmap _modmap = null; - public static void set_modmap(KeyboardData.Modmap mm) { _modmap = mm; } + public static void set_modmap(KeyboardData.Modmap mm) + { + // Clear the cache when switching to or from a layout that contain a modmap + // as the cache would otherwise override the modmap. + if (_modmap != null || mm != null) + _cache.clear(); + _modmap = mm; + } /** Modify a key according to modifiers. */ public static KeyValue modify(KeyValue k, Pointers.Modifiers mods)