Commit 887a8596 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Close layer-shell clients when associated output is disabled

When an output is disabled, it's not necessarily destroyed.
parent de9af6ed
......@@ -67,6 +67,11 @@ QByteArray AbstractOutput::uuid() const
return QByteArray();
}
bool AbstractOutput::isEnabled() const
{
return true;
}
void AbstractOutput::setEnabled(bool enable)
{
Q_UNUSED(enable)
......
......@@ -103,6 +103,11 @@ public:
*/
virtual QByteArray uuid() const;
/**
* Returns @c true if the output is enabled; otherwise returns @c false.
*/
virtual bool isEnabled() const;
/**
* Enable or disable the output.
*
......@@ -190,6 +195,10 @@ Q_SIGNALS:
* This signal is emitted when the geometry of this output has changed.
*/
void geometryChanged();
/**
* This signal is emitted when the output has been enabled or disabled.
*/
void enabledChanged();
private:
Q_DISABLE_COPY(AbstractOutput)
......
......@@ -240,6 +240,8 @@ void AbstractWaylandOutput::setEnabled(bool enable)
// xdg-output is destroyed in KWayland on wl_output going away.
updateEnablement(false);
}
emit enabledChanged();
}
QString AbstractWaylandOutput::description() const
......
......@@ -105,7 +105,7 @@ public:
return m_waylandOutput;
}
bool isEnabled() const;
bool isEnabled() const override;
/**
* Enable or disable the output.
*
......
......@@ -58,6 +58,8 @@ LayerShellV1Client::LayerShellV1Client(LayerSurfaceV1Interface *shellSurface,
connect(output, &AbstractOutput::geometryChanged,
this, &LayerShellV1Client::scheduleRearrange);
connect(output, &AbstractOutput::enabledChanged,
this, &LayerShellV1Client::handleOutputEnabledChanged);
connect(output, &AbstractOutput::destroyed,
this, &LayerShellV1Client::handleOutputDestroyed);
......@@ -256,6 +258,14 @@ void LayerShellV1Client::handleAcceptsFocusChanged()
}
}
void LayerShellV1Client::handleOutputEnabledChanged()
{
if (!m_output->isEnabled()) {
closeWindow();
destroyClient();
}
}
void LayerShellV1Client::handleOutputDestroyed()
{
closeWindow();
......
......@@ -54,6 +54,7 @@ private:
void handleUnmapped();
void handleCommitted();
void handleAcceptsFocusChanged();
void handleOutputEnabledChanged();
void handleOutputDestroyed();
void scheduleRearrange();
......
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