workspace: fix the dpms input event filter sometimes being wrongly deleted

Before, it could break in the following scenario:
- drm backend emits aboutToTurnOff
- workspace creates the dpms filter
- workspace gets some event that triggers it to update outputs
- maybeDestroyDpmsFilter sees that the output is on and deletes the dpms filter
- the drm backend actually turns the screen off

In that case, the dpms input event filter is gone and the output off. Unless the dpms mode
gets changed again by some other process, the output would now stay off forever.
wilder/Plasma/6.3
Xaver Hugl 1 year ago
parent d1b8919ef3
commit 8676141067
  1. 5
      src/backends/drm/drm_output.cpp
  2. 1
      src/core/output.h
  3. 1
      src/wayland/dpms.cpp

@ -143,6 +143,7 @@ void DrmOutput::setDpmsMode(DpmsMode mode)
{
if (mode == DpmsMode::Off) {
if (!m_turnOffTimer.isActive()) {
updateDpmsMode(DpmsMode::AboutToTurnOff);
Q_EMIT aboutToTurnOff(std::chrono::milliseconds(m_turnOffTimer.interval()));
m_turnOffTimer.start();
}
@ -159,8 +160,8 @@ bool DrmOutput::setDrmDpmsMode(DpmsMode mode)
if (!isEnabled()) {
return false;
}
bool active = mode == DpmsMode::On;
bool isActive = dpmsMode() == DpmsMode::On;
bool active = mode == DpmsMode::On || mode == DpmsMode::AboutToTurnOff;
bool isActive = dpmsMode() == DpmsMode::On || dpmsMode() == DpmsMode::AboutToTurnOff;
if (active == isActive) {
updateDpmsMode(mode);
return true;

@ -148,6 +148,7 @@ public:
Standby,
Suspend,
Off,
AboutToTurnOff,
};
Q_ENUM(DpmsMode)

@ -148,6 +148,7 @@ void DpmsInterface::sendMode()
org_kde_kwin_dpms_mode wlMode;
switch (mode) {
case Output::DpmsMode::On:
case Output::DpmsMode::AboutToTurnOff:
wlMode = ORG_KDE_KWIN_DPMS_MODE_ON;
break;
case Output::DpmsMode::Standby:

Loading…
Cancel
Save