Don't replace user selected dead keys

Don't replace dead-keys selected in the "Add keys to the keyboard"
option by an alternative.
This commit is contained in:
Jules Aguillon 2023-08-06 17:11:29 +02:00
parent 1eea9e25d2
commit 4d10556d49
2 changed files with 8 additions and 5 deletions

View File

@ -182,6 +182,8 @@ final class Config
// first iteration then automatically added. // first iteration then automatically added.
final Set<KeyValue> extra_keys = new HashSet<KeyValue>(); final Set<KeyValue> extra_keys = new HashSet<KeyValue>();
final Set<KeyValue> remove_keys = new HashSet<KeyValue>(); final Set<KeyValue> remove_keys = new HashSet<KeyValue>();
extra_keys.addAll(extra_keys_param);
extra_keys.addAll(extra_keys_custom);
if (extra_keys_subtype != null) if (extra_keys_subtype != null)
{ {
Set<KeyValue> present = new HashSet<KeyValue>(); Set<KeyValue> present = new HashSet<KeyValue>();
@ -191,8 +193,6 @@ final class Config
extra_keys_subtype.compute(extra_keys, extra_keys_subtype.compute(extra_keys,
new ExtraKeys.Query(kw.script, present)); new ExtraKeys.Query(kw.script, present));
} }
extra_keys.addAll(extra_keys_param);
extra_keys.addAll(extra_keys_custom);
boolean number_row = this.number_row && !show_numpad; boolean number_row = this.number_row && !show_numpad;
if (number_row) if (number_row)
KeyboardData.number_row.getKeys(remove_keys); KeyboardData.number_row.getKeys(remove_keys);

View File

@ -20,7 +20,8 @@ class ExtraKeys
_ks = ks; _ks = ks;
} }
/** Add the keys that should be added to the keyboard into [dst]. */ /** Add the keys that should be added to the keyboard into [dst]. Keys
already added to [dst] might have an impact, see [ExtraKey.compute]. */
public void compute(Set<KeyValue> dst, Query q) public void compute(Set<KeyValue> dst, Query q)
{ {
for (ExtraKey k : _ks) for (ExtraKey k : _ks)
@ -77,11 +78,13 @@ class ExtraKeys
// enforced to be complete by the merging step. The same [kv] will not // enforced to be complete by the merging step. The same [kv] will not
// appear again in the list of extra keys with a different list of // appear again in the list of extra keys with a different list of
// alternatives. // alternatives.
KeyValue k = (alternatives.size() == 1) ? alternatives.get(0) : kv; // Selecting the dead key in the "Add key to the keyboard" option would
// disable this behavior for a key.
boolean use_alternative = (alternatives.size() == 1 && !dst.contains(kv));
if if
((q.script == null || script == null || q.script.equals(script)) ((q.script == null || script == null || q.script.equals(script))
&& (alternatives.size() == 0 || !q.present.containsAll(alternatives))) && (alternatives.size() == 0 || !q.present.containsAll(alternatives)))
dst.add(k); dst.add(use_alternative ? alternatives.get(0) : kv);
} }
/** Return a new key from two. [kv] are expected to be equal. [script] is /** Return a new key from two. [kv] are expected to be equal. [script] is