mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(Brightness): Simplified the code to use existing functionality, also fixed a bug with enforcing the minimum brightness
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user