From 297557bde400a24f95e702d92f7d98fcb4070313 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Wed, 27 Feb 2019 12:52:44 +0200 Subject: [PATCH] [wayland] Implement belongsToDesktop check Summary: When user asks KWin to show desktop, the compositor just raises every desktop window, it doesn't attempt to minimize normal clients, etc. Because desktop windows contain stuff like background and icons, the compositor has to raise all clients that are somehow correlated with desktop (e.g. panels, etc). Otherwise it would pretty weird to show only desktop background. Currently, not all plasmashell's clients are raised when the compositor shows desktop because belongsToDesktop is not implemented for ShellClient. BUG: 404801 Test Plan: * Show desktop; * Open Kickoff (without this patch Kickoff is not visible). Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19386 --- shell_client.cpp | 31 ++++++++++++++++--------------- shell_client.h | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/shell_client.cpp b/shell_client.cpp index 13bd9f1c6c..ac5f98461e 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -449,6 +449,20 @@ void ShellClient::debug(QDebug &stream) const << resourceName() << ";Caption:" << caption() << "\'"; } +bool ShellClient::belongsToDesktop() const +{ + const auto clients = waylandServer()->clients(); + + return std::any_of(clients.constBegin(), clients.constEnd(), + [this](const ShellClient *client) { + if (belongsToSameApplication(client, SameApplicationChecks())) { + return client->isDesktop(); + } + return false; + } + ); +} + Layer ShellClient::layerForDock() const { if (m_plasmaShellSurface) { @@ -982,22 +996,9 @@ void ShellClient::takeFocus() setActive(true); } - bool breakShowingDesktop = !keepAbove() && !isOnScreenDisplay(); - if (breakShowingDesktop) { - // check that it doesn't belong to the desktop - const auto &clients = waylandServer()->clients(); - for (auto c: clients) { - if (!belongsToSameApplication(c, SameApplicationChecks())) { - continue; - } - if (c->isDesktop()) { - breakShowingDesktop = false; - break; - } - } - } - if (breakShowingDesktop) + if (!keepAbove() && !isOnScreenDisplay() && !belongsToDesktop()) { workspace()->setShowingDesktop(false); + } } void ShellClient::doSetActive() diff --git a/shell_client.h b/shell_client.h index 37ae822747..7c553eb003 100644 --- a/shell_client.h +++ b/shell_client.h @@ -167,6 +167,7 @@ protected: void addDamage(const QRegion &damage) override; bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const override; void doSetActive() override; + bool belongsToDesktop() const override; Layer layerForDock() const override; void changeMaximize(bool horizontal, bool vertical, bool adjust) override; void setGeometryRestore(const QRect &geo) override {