mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #2425 from spiros132/main
fix(Brightness): Fixes a bug with the bar widget, and also with the minimum enforce
This commit is contained in:
@@ -176,29 +176,18 @@ Item {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var shouldApplyToAll = root.applyToAllMonitors && root.getControllableMonitorCount() > 1;
|
var shouldApplyToAll = root.applyToAllMonitors && root.getControllableMonitorCount() > 1;
|
||||||
if (shouldApplyToAll) {
|
if (angle > 0) {
|
||||||
var direction = angle > 0 ? 1 : -1;
|
if (shouldApplyToAll) {
|
||||||
var baseValue = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness;
|
BrightnessService.increaseBrightness();
|
||||||
var step = monitor.stepSize;
|
|
||||||
var minValue = monitor.minBrightnessValue;
|
|
||||||
|
|
||||||
if (direction > 0 && Settings.data.brightness.enforceMinimum && baseValue < minValue) {
|
|
||||||
baseValue = Math.max(step, minValue);
|
|
||||||
} else {
|
} 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) {
|
} else if (angle < 0) {
|
||||||
monitor.decreaseBrightness();
|
if (shouldApplyToAll) {
|
||||||
|
BrightnessService.decreaseBrightness();
|
||||||
|
} else {
|
||||||
|
monitor.decreaseBrightness();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -478,7 +478,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setBrightness(value: real): void {
|
function setBrightness(value: real): void {
|
||||||
value = Math.max(0, Math.min(1, value));
|
var min = Settings.data.brightness.enforceMinimum && isDdc ? 0.01 : 0;
|
||||||
|
value = Math.max(min, Math.min(1, value));
|
||||||
var rounded = Math.round(value * 100);
|
var rounded = Math.round(value * 100);
|
||||||
|
|
||||||
// Always update internal value and trigger UI feedback immediately
|
// Always update internal value and trigger UI feedback immediately
|
||||||
|
|||||||
Reference in New Issue
Block a user