From 1466836ba74d1f9e1bf88de55ddcfb77c81678ac Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 15 Apr 2022 07:15:59 +0000 Subject: [PATCH] Inherit "Delete" and "Unmanaged" from AbstractClient Depends on !2224, !2232 Further changes are blocked until the above MR's are merged. --- src/deleted.cpp | 3 +-- src/deleted.h | 33 ++++++++++++++++++++++------ src/effects.cpp | 55 +++++++++++++++++++---------------------------- src/unmanaged.cpp | 2 +- src/unmanaged.h | 26 ++++++++++++++++++++-- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/deleted.cpp b/src/deleted.cpp index 913b6dbf5e..543a9456aa 100644 --- a/src/deleted.cpp +++ b/src/deleted.cpp @@ -9,7 +9,6 @@ #include "deleted.h" -#include "abstract_client.h" #include "group.h" #include "netinfo.h" #include "shadow.h" @@ -22,7 +21,7 @@ namespace KWin { Deleted::Deleted() - : Toplevel() + : AbstractClient() , delete_refcount(1) , m_frame(XCB_WINDOW_NONE) , m_layer(UnknownLayer) diff --git a/src/deleted.h b/src/deleted.h index 6072a4469a..1175b78b4e 100644 --- a/src/deleted.h +++ b/src/deleted.h @@ -10,14 +10,12 @@ #ifndef KWIN_DELETED_H #define KWIN_DELETED_H -#include "toplevel.h" +#include "abstract_client.h" namespace KWin { -class AbstractClient; - -class KWIN_EXPORT Deleted : public Toplevel +class KWIN_EXPORT Deleted : public AbstractClient { Q_OBJECT @@ -51,7 +49,7 @@ public: { return m_modal; } - QList mainClients() const + QList mainClients() const override { return m_mainClients; } @@ -62,7 +60,7 @@ public: } QByteArray windowRole() const override; - bool isFullScreen() const + bool isFullScreen() const override { return m_fullscreen; } @@ -75,11 +73,34 @@ public: { return m_keepBelow; } + QString caption() const { return m_caption; } + QString captionNormal() const override { return m_caption; } + QString captionSuffix() const override { return {}; } + bool isCloseable() const override { return false; } + bool isShown() const override { return false; } + bool isHiddenInternal() const override { return false; } + void hideClient() override { /* nothing to do */ } + void showClient() override { /* nothing to do */ } + AbstractClient *findModal(bool /*allow_itself*/) override { return nullptr; } + bool isResizable() const override { return false; } + bool isMovable() const override { return false; } + bool isMovableAcrossScreens() const override { return false; } + bool takeFocus() override { return false; } + bool wantsInput() const override { return false; } + void killWindow() override { /* nothing to do */ } + void destroyClient() override { /* nothing to do */ } + void closeWindow() override { /* nothing to do */ } + bool acceptsFocus() const override { return false; } + bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks /*checks*/) const override { return other == this; } + void moveResizeInternal(const QRect & /*rect*/, KWin::AbstractClient::MoveResizeMode /*mode*/) override { /* nothing to do */ } + void updateCaption() override { /* nothing to do */ } + void resizeWithChecks(const QSize&) override { /* nothing to do */ } + /** * Returns whether the client was a popup. * diff --git a/src/effects.cpp b/src/effects.cpp index 503d033826..cd8319425b 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -2073,7 +2073,7 @@ TOPLEVEL_HELPER(QUuid, internalId, internalId) #undef TOPLEVEL_HELPER -#define CLIENT_HELPER_WITH_DELETED(rettype, prototype, propertyname, defaultValue) \ +#define CLIENT_HELPER(rettype, prototype, propertyname, defaultValue) \ rettype EffectWindowImpl::prototype() const \ { \ auto client = static_cast(toplevel->isClient() ? toplevel : nullptr); \ @@ -2087,15 +2087,26 @@ TOPLEVEL_HELPER(QUuid, internalId, internalId) return defaultValue; \ } -CLIENT_HELPER_WITH_DELETED(bool, isMinimized, isMinimized, false) -CLIENT_HELPER_WITH_DELETED(bool, isModal, isModal, false) -CLIENT_HELPER_WITH_DELETED(bool, isFullScreen, isFullScreen, false) -CLIENT_HELPER_WITH_DELETED(bool, keepAbove, keepAbove, false) -CLIENT_HELPER_WITH_DELETED(bool, keepBelow, keepBelow, false) -CLIENT_HELPER_WITH_DELETED(QString, caption, caption, QString()); -CLIENT_HELPER_WITH_DELETED(QVector, desktops, x11DesktopIds, QVector()); +CLIENT_HELPER(bool, isMinimized, isMinimized, false) +CLIENT_HELPER(bool, isModal, isModal, false) +CLIENT_HELPER(bool, isFullScreen, isFullScreen, false) +CLIENT_HELPER(bool, keepAbove, keepAbove, false) +CLIENT_HELPER(bool, keepBelow, keepBelow, false) +CLIENT_HELPER(QString, caption, caption, QString()); +CLIENT_HELPER(QVector, desktops, x11DesktopIds, QVector()); +CLIENT_HELPER(bool, isMovable, isMovable, false) +CLIENT_HELPER(bool, isMovableAcrossScreens, isMovableAcrossScreens, false) +CLIENT_HELPER(bool, isUserMove, isInteractiveMove, false) +CLIENT_HELPER(bool, isUserResize, isInteractiveResize, false) +CLIENT_HELPER(QRect, iconGeometry, iconGeometry, QRect()) +CLIENT_HELPER(bool, isSpecialWindow, isSpecialWindow, true) +CLIENT_HELPER(bool, acceptsFocus, wantsInput, true) // We don't actually know... +CLIENT_HELPER(QIcon, icon, icon, QIcon()) +CLIENT_HELPER(bool, isSkipSwitcher, skipSwitcher, false) +CLIENT_HELPER(bool, decorationHasAlpha, decorationHasAlpha, false) +CLIENT_HELPER(bool, isUnresponsive, unresponsive, false) -#undef CLIENT_HELPER_WITH_DELETED +#undef CLIENT_HELPER // legacy from tab groups, can be removed when no effects use this any more. bool EffectWindowImpl::isCurrentTab() const @@ -2118,30 +2129,6 @@ NET::WindowType EffectWindowImpl::windowType() const return toplevel->windowType(); } -#define CLIENT_HELPER(rettype, prototype, propertyname, defaultValue) \ - rettype EffectWindowImpl::prototype() const \ - { \ - auto client = static_cast(toplevel->isClient() ? toplevel : nullptr); \ - if (client) { \ - return client->propertyname(); \ - } \ - return defaultValue; \ - } - -CLIENT_HELPER(bool, isMovable, isMovable, false) -CLIENT_HELPER(bool, isMovableAcrossScreens, isMovableAcrossScreens, false) -CLIENT_HELPER(bool, isUserMove, isInteractiveMove, false) -CLIENT_HELPER(bool, isUserResize, isInteractiveResize, false) -CLIENT_HELPER(QRect, iconGeometry, iconGeometry, QRect()) -CLIENT_HELPER(bool, isSpecialWindow, isSpecialWindow, true) -CLIENT_HELPER(bool, acceptsFocus, wantsInput, true) // We don't actually know... -CLIENT_HELPER(QIcon, icon, icon, QIcon()) -CLIENT_HELPER(bool, isSkipSwitcher, skipSwitcher, false) -CLIENT_HELPER(bool, decorationHasAlpha, decorationHasAlpha, false) -CLIENT_HELPER(bool, isUnresponsive, unresponsive, false) - -#undef CLIENT_HELPER - QSize EffectWindowImpl::basicUnit() const { if (auto client = qobject_cast(toplevel)) { @@ -2249,9 +2236,11 @@ EffectWindowList EffectWindowImpl::mainWindows() const if (auto client = static_cast(toplevel->isClient() ? toplevel : nullptr)) { return getMainWindows(client); } + if (auto deleted = static_cast(toplevel->isDeleted() ? toplevel : nullptr)) { return getMainWindows(deleted); } + return {}; } diff --git a/src/unmanaged.cpp b/src/unmanaged.cpp index 1aa1a8c4fd..23721ed40b 100644 --- a/src/unmanaged.cpp +++ b/src/unmanaged.cpp @@ -51,7 +51,7 @@ const NET::WindowTypes SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK = NET::NormalMask | NET::CriticalNotificationMask; Unmanaged::Unmanaged() - : Toplevel() + : AbstractClient() { switch (kwinApp()->operationMode()) { case Application::OperationModeXwayland: diff --git a/src/unmanaged.h b/src/unmanaged.h index 180a1e62ba..576cca00be 100644 --- a/src/unmanaged.h +++ b/src/unmanaged.h @@ -12,12 +12,12 @@ #include -#include "toplevel.h" +#include "abstract_client.h" namespace KWin { -class KWIN_EXPORT Unmanaged : public Toplevel +class KWIN_EXPORT Unmanaged : public AbstractClient { Q_OBJECT public: @@ -37,6 +37,28 @@ public: NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; bool isOutline() const override; + QString captionNormal() const override { return {}; } + QString captionSuffix() const override { return {}; } + bool isCloseable() const override { return false; } + bool isShown() const override { return false; } + bool isHiddenInternal() const override { return false; } + void hideClient() override { /* nothing to do */ } + void showClient() override { /* nothing to do */ } + AbstractClient *findModal(bool /*allow_itself*/) override { return nullptr; } + bool isResizable() const override { return false; } + bool isMovable() const override { return false; } + bool isMovableAcrossScreens() const override { return false; } + bool takeFocus() override { return false; } + bool wantsInput() const override { return false; } + void killWindow() override { /* nothing to do */ } + void destroyClient() override { /* nothing to do */ } + void closeWindow() override { /* nothing to do */ } + bool acceptsFocus() const override { return false; } + bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks /*checks*/) const override { return other == this; } + void moveResizeInternal(const QRect & /*rect*/, KWin::AbstractClient::MoveResizeMode /*mode*/) override { /* nothing to do */ } + void updateCaption() override { /* nothing to do */ } + void resizeWithChecks(const QSize&) override { /* nothing to do */ } + public Q_SLOTS: void release(ReleaseReason releaseReason = ReleaseReason::Release);