From 420c60adfcb95b09ab352b614fdd2dc2a66dcfa8 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 24 Oct 2020 01:06:56 +0000 Subject: [PATCH] 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 deaaa7dabb6f3b8bcea77c8a15bb2744a3b9172b) --- kded/daemon.cpp | 11 ++++++++--- kded/daemon.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kded/daemon.cpp b/kded/daemon.cpp index bfa6da8..ccd4738 100644 --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -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()) { diff --git a/kded/daemon.h b/kded/daemon.h index 188d294..706fd5d 100644 --- a/kded/daemon.h +++ b/kded/daemon.h @@ -71,7 +71,7 @@ private: void saveCurrentConfig(); void displayButton(); void lidClosedChanged(bool lidIsClosed); - void lidClosedTimeout(); + void disableLidOutput(); void setMonitorForChanges(bool enabled); void outputConnectedChanged(); -- GitLab