From 887a8596217433bfea707f661c561911373a9034 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 22 Jan 2021 10:22:24 +0200 Subject: [PATCH] wayland: Close layer-shell clients when associated output is disabled When an output is disabled, it's not necessarily destroyed. --- abstract_output.cpp | 5 +++++ abstract_output.h | 9 +++++++++ abstract_wayland_output.cpp | 2 ++ abstract_wayland_output.h | 2 +- layershellv1client.cpp | 10 ++++++++++ layershellv1client.h | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/abstract_output.cpp b/abstract_output.cpp index 25560bbace..7326e302f8 100644 --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -67,6 +67,11 @@ QByteArray AbstractOutput::uuid() const return QByteArray(); } +bool AbstractOutput::isEnabled() const +{ + return true; +} + void AbstractOutput::setEnabled(bool enable) { Q_UNUSED(enable) diff --git a/abstract_output.h b/abstract_output.h index 3538e4b56e..7ab0dc9732 100644 --- a/abstract_output.h +++ b/abstract_output.h @@ -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) diff --git a/abstract_wayland_output.cpp b/abstract_wayland_output.cpp index cbd3945f02..63a2512a94 100644 --- a/abstract_wayland_output.cpp +++ b/abstract_wayland_output.cpp @@ -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 diff --git a/abstract_wayland_output.h b/abstract_wayland_output.h index 370d2d6ae3..474f5c7591 100644 --- a/abstract_wayland_output.h +++ b/abstract_wayland_output.h @@ -105,7 +105,7 @@ public: return m_waylandOutput; } - bool isEnabled() const; + bool isEnabled() const override; /** * Enable or disable the output. * diff --git a/layershellv1client.cpp b/layershellv1client.cpp index 7e50393d67..a0ceba9753 100644 --- a/layershellv1client.cpp +++ b/layershellv1client.cpp @@ -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(); diff --git a/layershellv1client.h b/layershellv1client.h index 7c3e0cceb8..dfb6ce046c 100644 --- a/layershellv1client.h +++ b/layershellv1client.h @@ -54,6 +54,7 @@ private: void handleUnmapped(); void handleCommitted(); void handleAcceptsFocusChanged(); + void handleOutputEnabledChanged(); void handleOutputDestroyed(); void scheduleRearrange();