Commit 8622cfc9 authored by Oliver Henshaw's avatar Oliver Henshaw
Browse files

Cache whether screen powersaving is inhibited

DPMSAction disables or enables DPMS (and sets timeouts) as appropriate
when inhibition policy changes. As setting DPMS timeouts resets the
timer this will delay the time at which DPMS activates. But this is only
necessary if the ChangeScreenSettings inhibition changed.

Chrome sets short-lived InterruptSession inhibitions while uploading
data. This has the effect of indefinitely delaying DPMS activation.

So cache the current screen inhibition state and only decide whether to
enable or disable DPMS if the new state is different.

BUG: 314250
REVIEW: 109126
parent aaf804ae
......@@ -69,6 +69,7 @@ K_EXPORT_PLUGIN(PowerDevilDPMSActionFactory("powerdevildpmsaction"))
PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &args)
: Action(parent)
, m_idleTime(0)
, m_inhibitScreen(0) // can't use PowerDevil::PolicyAgent enum because X11/X.h defines None as 0L
, d(new Private)
......@@ -98,6 +99,8 @@ PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &
// inhibitions persist over kded module unload/load
m_inhibitScreen = PowerDevil::PolicyAgent::instance()->unavailablePolicies() & PowerDevil::PolicyAgent::ChangeScreenSettings;
......@@ -207,7 +210,14 @@ bool PowerDevilDPMSAction::onUnloadAction()
void PowerDevilDPMSAction::onUnavailablePoliciesChanged(PowerDevil::PolicyAgent::RequiredPolicies policies)
if (policies & PowerDevil::PolicyAgent::ChangeScreenSettings) {
// only take action if screen inhibit changed
PowerDevil::PolicyAgent::RequiredPolicies oldPolicy = m_inhibitScreen;
m_inhibitScreen = policies & PowerDevil::PolicyAgent::ChangeScreenSettings;
if (oldPolicy == m_inhibitScreen) {
if (m_inhibitScreen) {
// Inhibition triggered: disable DPMS
kDebug() << "Disabling DPMS due to inhibition";
Display *dpy = QX11Info::display();
......@@ -49,6 +49,7 @@ private Q_SLOTS:
int m_idleTime;
PowerDevil::PolicyAgent::RequiredPolicies m_inhibitScreen;
class Private;
Private * const d;
Supports Markdown
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