Commit 1ad7718a authored by Oliver Henshaw's avatar Oliver Henshaw
Browse files

Don't set unwanted DPMS timeouts on inhibition change

Set m_idleTime to zero when action first initialised and when unloaded.
This makes onProfileLoad safe to use by onUnavailablePoliciesChanged
even when the action is not loaded.

CCBUG: 295164
REVIEW: 106793
(cherry picked from commit 7626961a)
parent 39bf5c05
......@@ -68,6 +68,7 @@ K_EXPORT_PLUGIN(PowerDevilDPMSActionFactory("powerdevildpmsaction"))
PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &args)
: Action(parent)
, m_idleTime(0)
, d(new Private)
{
setRequiredPolicies(PowerDevil::PolicyAgent::ChangeScreenSettings);
......@@ -147,6 +148,9 @@ void PowerDevilDPMSAction::onProfileLoad()
XFlush(dpy);
XSetErrorHandler(d->defaultHandler);
// An unloaded action will have m_idleTime = 0:
// DPMS enabled with zeroed timeouts is effectively disabled.
// So onProfileLoad is always safe
DPMSSetTimeouts(dpy, (CARD16)m_idleTime, (CARD16)(m_idleTime * 1.5), (CARD16)(m_idleTime * 2));
XFlush(dpy);
......@@ -194,6 +198,12 @@ bool PowerDevilDPMSAction::loadAction(const KConfigGroup& config)
return true;
}
bool PowerDevilDPMSAction::onUnloadAction()
{
m_idleTime = 0;
return Action::onUnloadAction();
}
void PowerDevilDPMSAction::onUnavailablePoliciesChanged(PowerDevil::PolicyAgent::RequiredPolicies policies)
{
if (policies & PowerDevil::PolicyAgent::ChangeScreenSettings) {
......
......@@ -34,6 +34,7 @@ public:
protected:
virtual void onProfileUnload();
virtual bool onUnloadAction();
virtual void onWakeupFromIdle();
virtual void onIdleTimeout(int msec);
virtual void onProfileLoad();
......
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