Skip to content

fix: avoid redundant keyboard brightness writes during state changes - #957

Open
anhthinhvup wants to merge 1 commit into
1kc:masterfrom
anhthinhvup:fix/state-manager-fade-619
Open

fix: avoid redundant keyboard brightness writes during state changes#957
anhthinhvup wants to merge 1 commit into
1kc:masterfrom
anhthinhvup:fix/state-manager-fade-619

Conversation

@anhthinhvup

@anhthinhvup anhthinhvup commented May 11, 2026

Copy link
Copy Markdown

Summary

  • avoid redundant keyboard brightness writes when applying a saved state
  • keep brightness updates when the saved state actually changes brightness

Root cause

StateManager.activateState() reapplies the device mode and then calls RazerDeviceKeyboard.resetToState(), which always called setBrightness(state.brightness) even when the keyboard was already at that brightness.

For regular color changes from the menu, the app only sends the lighting mode command. For state-manager transitions, it sends an extra brightness command every time. On the BlackWidow Chroma Tournament Edition, that redundant brightness write appears to interrupt the hardware fade and makes the transition look like a flash.

Fix

Only call setBrightness() when the saved state actually has a brightness value and that value differs from the current keyboard brightness.

Verification

  • Reproduced the old behavior with an inline regression harness that loads the current RazerDevice and RazerDeviceKeyboard source, mocks the addon, and verifies resetToState() called KbdSetBrightness() even when brightness stayed at 80.
  • Re-ran the same harness after the patch and confirmed:
    • unchanged brightness does not call KbdSetBrightness()
    • changed brightness still calls KbdSetBrightness()
  • Ran git diff --check

Bounty

Fixes #619
IssueHunt: https://issuehunt.io/r/1kc/razer-macos/issues/619


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlackWidow Chroma Tournament Edition doesn't fade when changing states

1 participant