From 348e20e20fa4e3a3a40eb37ecfb71aea59b0bb09 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 18 Apr 2022 11:22:33 +0300 Subject: [PATCH] Remove AbstractClient plumbing casts in Workspace --- src/activation.cpp | 5 ++--- src/useractions.cpp | 5 ++--- src/workspace.cpp | 17 +++++++---------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/activation.cpp b/src/activation.cpp index 32bb248937..899eb2a33d 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -424,9 +424,8 @@ AbstractClient *Workspace::clientUnderMouse(Output *output) const { auto it = stackingOrder().constEnd(); while (it != stackingOrder().constBegin()) { - auto t = *(--it); - auto client = static_cast(t->isClient() ? t : nullptr); - if (!client) { + auto client = *(--it); + if (!client->isClient()) { continue; } diff --git a/src/useractions.cpp b/src/useractions.cpp index 6c67a6771d..d510280a46 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -1679,9 +1679,8 @@ bool Workspace::switchWindow(AbstractClient *c, Direction direction, QPoint curP QList clist = stackingOrder(); for (auto i = clist.rbegin(); i != clist.rend(); ++i) { - auto t = *i; - auto client = static_cast(t->isClient() ? t : nullptr); - if (!client) { + auto client = *i; + if (!client->isClient()) { continue; } if (client->wantsTabFocus() && *i != c && client->isOnDesktop(desktop) && !client->isMinimized() && (*i)->isOnCurrentActivity()) { diff --git a/src/workspace.cpp b/src/workspace.cpp index f8e576c755..ccb2fc6b4f 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -896,9 +896,8 @@ void Workspace::updateToolWindows(bool also_hide) // SELI TODO: But maybe it should - what if a new client has been added that's not in stacking order yet? QVector to_show, to_hide; for (auto it = stacking_order.constBegin(); it != stacking_order.constEnd(); ++it) { - auto t = *it; - auto c = static_cast(t->isClient() ? t : nullptr); - if (!c) { + auto c = *it; + if (!c->isClient()) { continue; } if (c->isUtility() || c->isMenu() || c->isToolbar()) { @@ -1109,9 +1108,8 @@ AbstractClient *Workspace::findClientToActivateOnDesktop(VirtualDesktop *desktop if (options->isNextFocusPrefersMouse()) { auto it = stackingOrder().constEnd(); while (it != stackingOrder().constBegin()) { - auto t = *(--it); - auto client = static_cast(t->isClient() ? t : nullptr); - if (!client) { + auto client = *(--it); + if (!client->isClient()) { continue; } @@ -1421,9 +1419,8 @@ void Workspace::setShowingDesktop(bool showing, bool animated) { // for the blocker RAII StackingUpdatesBlocker blocker(this); // updateLayer & lowerClient would invalidate stacking_order for (int i = stacking_order.count() - 1; i > -1; --i) { - auto t = stacking_order.at(i); - auto c = static_cast(t->isClient() ? t : nullptr); - if (c && c->isOnCurrentDesktop()) { + auto c = stacking_order.at(i); + if (c->isClient() && c->isOnCurrentDesktop()) { if (c->isDock()) { c->updateLayer(); } else if (c->isDesktop() && c->isShown()) { @@ -1802,7 +1799,7 @@ AbstractClient *Workspace::findAbstractClient(std::function(t && t->isClient() ? t : nullptr); + return t && t->isClient() ? t : nullptr; } Unmanaged *Workspace::findUnmanaged(std::function func) const