From a106a5aab8f507106dfeec0af2b83e157e5146d0 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 26 May 2021 12:34:35 +0300 Subject: [PATCH] Move AbstractClient::isShade() to Toplevel This simplifies rendering code and allows to cache properly the shaded state for Deleted windows. --- src/abstract_client.h | 3 +-- src/deleted.cpp | 2 ++ src/deleted.h | 4 ++++ src/scene.cpp | 4 +--- src/toplevel.h | 6 ++++++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/abstract_client.h b/src/abstract_client.h index f0495c668e..a5444f317a 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -521,7 +521,7 @@ public: /** * @c true only for @c ShadeNormal */ - bool isShade() const { + bool isShade() const override { return shadeMode() == ShadeNormal; } ShadeMode shadeMode() const; // Prefer isShade() @@ -918,7 +918,6 @@ Q_SIGNALS: void desktopChanged(); void activitiesChanged(KWin::AbstractClient* client); void x11DesktopIdsChanged(); - void shadeChanged(); void minimizedChanged(); void clientMinimized(KWin::AbstractClient* client, bool animate); void clientUnminimized(KWin::AbstractClient* client, bool animate); diff --git a/src/deleted.cpp b/src/deleted.cpp index 180df19904..d82afea4b4 100644 --- a/src/deleted.cpp +++ b/src/deleted.cpp @@ -25,6 +25,7 @@ Deleted::Deleted() , delete_refcount(1) , m_frame(XCB_WINDOW_NONE) , m_layer(UnknownLayer) + , m_shade(false) , m_minimized(false) , m_modal(false) , m_wasClient(false) @@ -78,6 +79,7 @@ void Deleted::copyToDeleted(Toplevel* c) m_frame = c->frameId(); m_type = c->windowType(); m_windowRole = c->windowRole(); + m_shade = c->isShade(); if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info)) cinfo->disable(); if (AbstractClient *client = dynamic_cast(c)) { diff --git a/src/deleted.h b/src/deleted.h index 9165abe46c..d020128058 100644 --- a/src/deleted.h +++ b/src/deleted.h @@ -40,6 +40,9 @@ public: Layer layer() const override { return m_layer; } + bool isShade() const override { + return m_shade; + } bool isMinimized() const { return m_minimized; } @@ -113,6 +116,7 @@ private: QRect decoration_top; QRect decoration_bottom; Layer m_layer; + bool m_shade; bool m_minimized; bool m_modal; QList m_mainClients; diff --git a/src/scene.cpp b/src/scene.cpp index 839d9e3a50..c7f4e65318 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -836,9 +836,7 @@ bool Scene::Window::isOpaque() const bool Scene::Window::isShaded() const { - if (AbstractClient *client = qobject_cast(toplevel)) - return client->isShade(); - return false; + return toplevel->isShade(); } bool Scene::Window::isPaintingEnabled() const diff --git a/src/toplevel.h b/src/toplevel.h index 02ce5b7518..5f5616016b 100644 --- a/src/toplevel.h +++ b/src/toplevel.h @@ -562,7 +562,13 @@ public: return m_internalId; } + /** + * Returns @c true if the window is shaded; otherwise returns @c false. + */ + virtual bool isShade() const { return false; } + Q_SIGNALS: + void shadeChanged(); void markedAsZombie(); void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); void damaged(KWin::Toplevel* toplevel, const QRegion& damage);