From 6ca6308ccd2f3266f20f84af6658fa97547e12ee Mon Sep 17 00:00:00 2001 From: Jakob Petsovits Date: Wed, 17 Jul 2024 12:29:20 +0200 Subject: [PATCH] wayland: Use brightness range 1..max for internal displays This avoids regressing compared to PowerDevil in 6.1 which also protected against setting internal display brightness to 0. CCBUG: 430439 CCBUG: 483490 --- src/wayland/externalbrightness_v1.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wayland/externalbrightness_v1.cpp b/src/wayland/externalbrightness_v1.cpp index 0cf78f38bf..9c6dfa0478 100644 --- a/src/wayland/externalbrightness_v1.cpp +++ b/src/wayland/externalbrightness_v1.cpp @@ -60,7 +60,8 @@ ExternalBrightnessDeviceV1::~ExternalBrightnessDeviceV1() void ExternalBrightnessDeviceV1::setBrightness(double brightness) { - const uint32_t val = std::clamp(std::round(brightness * m_maxBrightness), 0, m_maxBrightness); + const uint32_t minBrightness = m_internal ? 1 : 0; // some laptop screens turn off at brightness 0 + const uint32_t val = std::round(std::lerp(minBrightness, m_maxBrightness, std::clamp(brightness, 0.0, 1.0))); send_requested_brightness(val); }