Commit 51bfadab authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

backends/wayland: Fix behaviour when disabling outputs

Makes sure disabled outputs are reported as such, leaving behind the
assumption that all outputs are always enabled.
Ensures the corresponding outputEnabled/Disabled signals are emitted.
Updates the window title to reflect the output state.
parent 465aa7ed
Pipeline #184071 passed with stage
in 15 minutes and 3 seconds
......@@ -970,8 +970,13 @@ Outputs WaylandBackend::outputs() const
Outputs WaylandBackend::enabledOutputs() const
{
// all outputs are enabled
return m_outputs;
Outputs ret;
for (auto o : m_outputs) {
if (o->isEnabled()) {
ret << o;
}
}
return ret;
}
void WaylandBackend::addConfiguredOutput(WaylandOutput *output)
......
......@@ -82,6 +82,10 @@ void WaylandOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixe
void WaylandOutput::updateEnablement(bool enable)
{
setDpmsMode(enable ? DpmsMode::On : DpmsMode::Off);
if (enable)
Q_EMIT m_backend->outputEnabled(this);
else
Q_EMIT m_backend->outputDisabled(this);
}
void WaylandOutput::setDpmsMode(DpmsMode mode)
......@@ -112,6 +116,8 @@ XdgShellOutput::XdgShellOutput(Surface *surface, XdgShell *xdgShell, WaylandBack
connect(m_xdgShellSurface, &XdgShellSurface::configureRequested, this, &XdgShellOutput::handleConfigure);
connect(m_xdgShellSurface, &XdgShellSurface::closeRequested, qApp, &QCoreApplication::quit);
connect(this, &WaylandOutput::enabledChanged, this, &XdgShellOutput::updateWindowTitle);
connect(this, &WaylandOutput::dpmsModeChanged, this, &XdgShellOutput::updateWindowTitle);
connect(backend, &WaylandBackend::pointerLockSupportedChanged, this, &XdgShellOutput::updateWindowTitle);
connect(backend, &WaylandBackend::pointerLockChanged, this, [this](bool locked) {
......@@ -164,14 +170,18 @@ void XdgShellOutput::updateWindowTitle()
} else if (backend()->pointerConstraints()) {
grab = i18n("Press right control key to grab pointer");
}
const QString title = i18nc("Title of nested KWin Wayland with Wayland socket identifier as argument",
"KDE Wayland Compositor #%1 (%2)", m_number, waylandServer()->socketName());
if (grab.isEmpty()) {
m_xdgShellSurface->setTitle(title);
} else {
m_xdgShellSurface->setTitle(title + QStringLiteral(" — ") + grab);
QString title = i18nc("Title of nested KWin Wayland with Wayland socket identifier as argument",
"KDE Wayland Compositor #%1 (%2) %3", m_number, waylandServer()->socketName());
if (!isEnabled()) {
title += i18n("- Output disabled");
} else if (dpmsMode() != DpmsMode::On) {
title += i18n("- Output dimmed");
} else if (!grab.isEmpty()) {
title += QStringLiteral(" — ") + grab;
}
m_xdgShellSurface->setTitle(title);
}
void XdgShellOutput::lockPointer(Pointer *pointer, bool lock)
......
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