Skip to content

Commit 087f753

Browse files
authored
Merge pull request #2425 from spiros132/main
fix(Brightness): Fixes a bug with the bar widget, and also with the minimum enforce
2 parents 5d03bf3 + 034b4ad commit 087f753

2 files changed

Lines changed: 11 additions & 21 deletions

File tree

Modules/Bar/Widgets/Brightness.qml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,29 +176,18 @@ Item {
176176
return;
177177

178178
var shouldApplyToAll = root.applyToAllMonitors && root.getControllableMonitorCount() > 1;
179-
if (shouldApplyToAll) {
180-
var direction = angle > 0 ? 1 : -1;
181-
var baseValue = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness;
182-
var step = monitor.stepSize;
183-
var minValue = monitor.minBrightnessValue;
184-
185-
if (direction > 0 && Settings.data.brightness.enforceMinimum && baseValue < minValue) {
186-
baseValue = Math.max(step, minValue);
179+
if (angle > 0) {
180+
if (shouldApplyToAll) {
181+
BrightnessService.increaseBrightness();
187182
} else {
188-
baseValue = baseValue + direction * step;
183+
monitor.increaseBrightness();
189184
}
190-
191-
var targetValue = Math.max(minValue, Math.min(1, baseValue));
192-
193-
BrightnessService.monitors.forEach(function (m) {
194-
if (m && m.brightnessControlAvailable) {
195-
m.setBrightnessDebounced(targetValue);
196-
}
197-
});
198-
} else if (angle > 0) {
199-
monitor.increaseBrightness();
200185
} else if (angle < 0) {
201-
monitor.decreaseBrightness();
186+
if (shouldApplyToAll) {
187+
BrightnessService.decreaseBrightness();
188+
} else {
189+
monitor.decreaseBrightness();
190+
}
202191
}
203192
}
204193

Services/Hardware/BrightnessService.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ Singleton {
478478
}
479479

480480
function setBrightness(value: real): void {
481-
value = Math.max(0, Math.min(1, value));
481+
var min = Settings.data.brightness.enforceMinimum && isDdc ? 0.01 : 0;
482+
value = Math.max(min, Math.min(1, value));
482483
var rounded = Math.round(value * 100);
483484

484485
// Always update internal value and trigger UI feedback immediately

0 commit comments

Comments
 (0)