fix(Brightness): Simplified the code to use existing functionality, also fixed a bug with enforcing the minimum brightness

This commit is contained in:
Spyridon Siarapis
2026-04-08 17:40:41 +02:00
parent f3ed6d0a2f
commit 58d5c3ad55
2 changed files with 11 additions and 21 deletions
+9 -20
View File
@@ -176,29 +176,18 @@ Item {
return;
var shouldApplyToAll = root.applyToAllMonitors && root.getControllableMonitorCount() > 1;
if (shouldApplyToAll) {
var direction = angle > 0 ? 1 : -1;
var baseValue = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness;
var step = monitor.stepSize;
var minValue = monitor.minBrightnessValue;
if (direction > 0 && Settings.data.brightness.enforceMinimum && baseValue < minValue) {
baseValue = Math.max(step, minValue);
if (angle > 0) {
if (shouldApplyToAll) {
BrightnessService.increaseBrightness();
} else {
baseValue = baseValue + direction * step;
monitor.increaseBrightness();
}
var targetValue = Math.max(minValue, Math.min(1, baseValue));
BrightnessService.monitors.forEach(function (m) {
if (m && m.brightnessControlAvailable) {
m.setBrightnessDebounced(targetValue);
}
});
} else if (angle > 0) {
monitor.increaseBrightness();
} else if (angle < 0) {
monitor.decreaseBrightness();
if (shouldApplyToAll) {
BrightnessService.decreaseBrightness();
} else {
monitor.decreaseBrightness();
}
}
}