Commit 692bb264 authored by Алексей Шилин's avatar Алексей Шилин Committed by Nathaniel Graham

Fix brightness not restoring when an inhibition is active

Summary:
BUG: 352497

An active inhibition with ChangeScreenSettings policy won't
allow to restore dimmed screen brightness normally. In this
case the user will be left with a barely visible screen,
requiring him/her to manually adjust the brightness back to
normal.

This commit enforces dimmed screen brightness restoration
even if ChangeScreenSettings policy is unavailable.

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: ngraham, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8502
parent dc5332a6
......@@ -45,7 +45,9 @@ void DimDisplay::onWakeupFromIdle()
if (!m_dimmed) {
return;
}
setBrightnessHelper(m_oldScreenBrightness, m_oldKeyboardBrightness);
// An active inhibition may not let us restore the brightness.
// Let's override it so that we don't leave the user with a dimmed screen.
setBrightnessHelper(m_oldScreenBrightness, m_oldKeyboardBrightness, true);
m_dimmed = false;
}
......@@ -80,11 +82,12 @@ void DimDisplay::onProfileLoad()
//
}
void DimDisplay::setBrightnessHelper(int screen, int keyboard)
void DimDisplay::setBrightnessHelper(int screen, int keyboard, bool force)
{
trigger({
{QStringLiteral("_ScreenBrightness"), QVariant::fromValue(screen)},
{QStringLiteral("_KeyboardBrightness"), QVariant::fromValue(keyboard)}
{QStringLiteral("_KeyboardBrightness"), QVariant::fromValue(keyboard)},
{QStringLiteral("Explicit"), QVariant::fromValue(force)}
});
}
......
......@@ -48,7 +48,7 @@ public:
bool loadAction(const KConfigGroup& config) Q_DECL_OVERRIDE;
private:
void setBrightnessHelper(int screen, int keyboard);
void setBrightnessHelper(int screen, int keyboard, bool force = false);
int m_dimOnIdleTime = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment