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:
parent
53e379fd24
commit
1d1a0915f1
|
|
@ -100,11 +100,9 @@ _EFFECT_STATIC = 0x01
|
||||||
|
|
||||||
def perkey_has_paint(device):
|
def perkey_has_paint(device):
|
||||||
"""Return ``(perkey_setting, has_paint)``. has_paint is True when the
|
"""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
|
per-key buffer has at least one real color and the user hasn't opted
|
||||||
user has *explicitly enabled* per-key via the lock icon (sensitivity
|
out via the lock icon (sensitivity == IGNORE). The locked-but-applied
|
||||||
is True). Default-sensitivity (False) and ignore both yield False so
|
state (False) still counts as paint."""
|
||||||
zone effects remain the primary mechanism on devices where the user
|
|
||||||
hasn't opted in to per-key dominance."""
|
|
||||||
perkey = None
|
perkey = None
|
||||||
for s in getattr(device, "settings", []) or []:
|
for s in getattr(device, "settings", []) or []:
|
||||||
if s.name == "per-key-lighting":
|
if s.name == "per-key-lighting":
|
||||||
|
|
@ -127,7 +125,7 @@ def perkey_has_paint(device):
|
||||||
no_change = special_keys.COLORSPLUS["No change"]
|
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()):
|
if not any(c != no_change and isinstance(c, int) and c >= 0 for c in value.values()):
|
||||||
return perkey, False
|
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, False
|
||||||
return perkey, True
|
return perkey, True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,14 +310,12 @@ def test_perkey_has_paint_with_real_colors():
|
||||||
assert has_paint is True
|
assert has_paint is True
|
||||||
|
|
||||||
|
|
||||||
def test_perkey_has_paint_requires_explicit_opt_in():
|
def test_perkey_has_paint_with_locked_sensitivity():
|
||||||
# Paint exists but sensitivity is the default (False) — has_paint must
|
# False (locked) still counts as paint — only IGNORE opts out.
|
||||||
# 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).
|
|
||||||
pk = _FakePerKey({1: 0xFF0000})
|
pk = _FakePerKey({1: 0xFF0000})
|
||||||
dev = _FakeDevice([pk], _FakePersister()) # sensitivity defaults to False
|
dev = _FakeDevice([pk], _FakePersister()) # sensitivity defaults to False
|
||||||
_, has_paint = rgb_power.perkey_has_paint(dev)
|
_, 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():
|
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():
|
def test_perkey_has_paint_with_no_persister():
|
||||||
# No persister means no place to record the user opting in, so per-key
|
# No persister, no IGNORE flag — treat as paint present.
|
||||||
# dominance never engages — zone effects remain primary.
|
|
||||||
pk = _FakePerKey({1: 0xFF0000})
|
pk = _FakePerKey({1: 0xFF0000})
|
||||||
dev = _FakeDevice([pk], persister=None)
|
dev = _FakeDevice([pk], persister=None)
|
||||||
_, has_paint = rgb_power.perkey_has_paint(dev)
|
_, 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():
|
def test_zone_effect_is_static_true_for_static():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue