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

When an output is disabled, it's not necessarily destroyed.
icc-effect-5.26.4
Vlad Zahorodnii 2021-01-22 10:22:24 +02:00
parent de9af6edce
commit 887a859621
6 changed files with 28 additions and 1 deletions

View File

@ -67,6 +67,11 @@ QByteArray AbstractOutput::uuid() const
return QByteArray();
}
bool AbstractOutput::isEnabled() const
{
return true;
}
void AbstractOutput::setEnabled(bool enable)
{
Q_UNUSED(enable)

View File

@ -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)

View File

@ -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

View File

@ -105,7 +105,7 @@ public:
return m_waylandOutput;
}
bool isEnabled() const;
bool isEnabled() const override;
/**
* Enable or disable the output.
*

View File

@ -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();

View File

@ -54,6 +54,7 @@ private:
void handleUnmapped();
void handleCommitted();
void handleAcceptsFocusChanged();
void handleOutputEnabledChanged();
void handleOutputDestroyed();
void scheduleRearrange();