rgb_power.perkey_has_paint: gate on IGNORE only, not on != True

The locked-but-applied sensitivity state (False) means the user can't
change the setting from the UI — not that the value should be ignored.
Per-key paint written under sensitivity=False is still on the device's
LEDs and still the dominant layer; gating it out caused the idle dim
ramp to push zone Static over a still-visible per-key buffer, making
the per-key layer vanish instead of fade.
This commit is contained in:
Ken Sanislo 2026-05-13 15:42:57 -07:00 committed by Peter F. Patel-Schneider
parent 53e379fd24
commit 1d1a0915f1
2 changed files with 9 additions and 14 deletions

View File

@ -100,11 +100,9 @@ _EFFECT_STATIC = 0x01
def perkey_has_paint(device):
"""Return ``(perkey_setting, has_paint)``. has_paint is True when the
per-key buffer has at least one real color, a usable zone set, and the
user has *explicitly enabled* per-key via the lock icon (sensitivity
is True). Default-sensitivity (False) and ignore both yield False so
zone effects remain the primary mechanism on devices where the user
hasn't opted in to per-key dominance."""
per-key buffer has at least one real color and the user hasn't opted
out via the lock icon (sensitivity == IGNORE). The locked-but-applied
state (False) still counts as paint."""
perkey = None
for s in getattr(device, "settings", []) or []:
if s.name == "per-key-lighting":
@ -127,7 +125,7 @@ def perkey_has_paint(device):
no_change = special_keys.COLORSPLUS["No change"]
if not any(c != no_change and isinstance(c, int) and c >= 0 for c in value.values()):
return perkey, False
if persister is None or persister.get_sensitivity("per-key-lighting") is not True:
if persister is not None and persister.get_sensitivity("per-key-lighting") == settings.SENSITIVITY_IGNORE:
return perkey, False
return perkey, True

View File

@ -310,14 +310,12 @@ def test_perkey_has_paint_with_real_colors():
assert has_paint is True
def test_perkey_has_paint_requires_explicit_opt_in():
# Paint exists but sensitivity is the default (False) — has_paint must
# be False so zone effects remain primary on devices where the user
# hasn't opted in to per-key dominance (e.g. G502X mouse out of the box).
def test_perkey_has_paint_with_locked_sensitivity():
# False (locked) still counts as paint — only IGNORE opts out.
pk = _FakePerKey({1: 0xFF0000})
dev = _FakeDevice([pk], _FakePersister()) # sensitivity defaults to False
_, has_paint = rgb_power.perkey_has_paint(dev)
assert has_paint is False
assert has_paint is True
def test_perkey_has_paint_only_no_change():
@ -354,12 +352,11 @@ def test_perkey_has_paint_user_ignores_perkey():
def test_perkey_has_paint_with_no_persister():
# No persister means no place to record the user opting in, so per-key
# dominance never engages — zone effects remain primary.
# No persister, no IGNORE flag — treat as paint present.
pk = _FakePerKey({1: 0xFF0000})
dev = _FakeDevice([pk], persister=None)
_, has_paint = rgb_power.perkey_has_paint(dev)
assert has_paint is False
assert has_paint is True
def test_zone_effect_is_static_true_for_static():