Commit 420c60ad authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez

daemon: improve consistency of the lid behaviour

We already had some behaviour for the case where the lid closes, we were
not applying it when initialising the daemon though, so a laptop would
start showing the screen to the keyboard until the user takes action.

This change addresses it so that upon initialising we run the same code
we would run if we closed the lid.


(cherry picked from commit deaaa7da)
parent 7a12f85a
......@@ -106,7 +106,7 @@ void KScreenDaemon::init()
m_lidClosedTimer->setInterval(1000);
m_lidClosedTimer->setSingleShot(true);
connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::lidClosedTimeout);
connect(m_lidClosedTimer, &QTimer::timeout, this, &KScreenDaemon::disableLidOutput);
connect(Device::self(), &Device::lidClosedChanged, this, &KScreenDaemon::lidClosedChanged);
connect(Device::self(), &Device::resumingFromSuspend, this,
......@@ -126,6 +126,11 @@ void KScreenDaemon::init()
connect(Generator::self(), &Generator::ready, this, [this] {
applyConfig();
if (Device::self()->isLaptop() && Device::self()->isLidClosed()) {
disableLidOutput();
}
m_startingUp = false;
});
......@@ -405,7 +410,7 @@ void KScreenDaemon::lidClosedChanged(bool lidIsClosed)
}
}
void KScreenDaemon::lidClosedTimeout()
void KScreenDaemon::disableLidOutput()
{
// Make sure nothing has changed in the past second... :-)
if (!Device::self()->isLidClosed()) {
......@@ -419,7 +424,7 @@ void KScreenDaemon::lidClosedTimeout()
// what's the configured action for lid events, but there's no API to do that
// and I'm not parsing PowerDevil's configs...
qCDebug(KSCREEN_KDED) << "Lid closed without system going to suspend -> turning off the screen";
qCDebug(KSCREEN_KDED) << "Lid closed, finding lid to disable";
for (KScreen::OutputPtr &output : m_monitoredConfig->data()->outputs()) {
if (output->type() == KScreen::Output::Panel) {
if (output->isConnected() && output->isEnabled()) {
......
......@@ -71,7 +71,7 @@ private:
void saveCurrentConfig();
void displayButton();
void lidClosedChanged(bool lidIsClosed);
void lidClosedTimeout();
void disableLidOutput();
void setMonitorForChanges(bool enabled);
void outputConnectedChanged();
......
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