fix(backlight): clamp scroll step to min-brightness#5210
Open
gitmpr wants to merge 1 commit into
Open
Conversation
When min-brightness is set, a scroll step that would cross it was not clamped — only scrolling while already at or below min was blocked. With scroll-step: 5 and min-brightness: 1, scrolling from 5% would pass the guard (5 > 1) and set brightness to 0%. Fix by computing the post-step value before applying it: if it would fall below min-brightness, set exactly to min-brightness instead.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When
min-brightnessis set, a scroll step that would cross it wasn't being clamped. Only scrolling while already at or below the minimum was blocked. Withscroll-step: 5andmin-brightness: 1, scrolling from 5% passes the guard (5 > 1) and sets brightness to 0%.The check in
handleScrollin src/modules/backlight.cpp was:This blocks further decrease once you're already at the minimum, but doesn't prevent a step from landing below it.
The fix computes whether the post-step value would fall below
min-brightnessand, if so, sets exactlymin-brightnessinstead of applying the full step.Why does this matter?
On
intel_backlight(typeraw, no kernel-enforced minimum), the kernel and logind both accept brightness 0, which on most laptop panels is a completely black screen. This makes the issue a real usability problem rather than just a cosmetic one. Users settingmin-brightness: 1to prevent this are silently unprotected when scrolling in steps larger than 1.Tested on
intel_backlight, max_brightness 7500. Confirmed bug on unpatched master, confirmed fix on this branch.Relates to #5209 (which adds
min-brightnessto the default config, which is complementary, but without this fix the protection has gaps wheneverscroll-step > 1).