From 433b753360965f014edeb8f492b39a5558dc5fe8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 20 Nov 2023 15:02:51 +0200 Subject: [PATCH] Drop EffectWindowList Use `QList` instead. --- src/effect/effects.cpp | 20 +++++++++---------- src/effect/effects.h | 12 +++++------ src/plugins/backgroundcontrast/contrast.cpp | 4 ++-- src/plugins/blendchanges/blendchanges.cpp | 4 ++-- .../highlightwindow/highlightwindow.cpp | 4 ++-- src/plugins/slide/slide.cpp | 2 +- src/plugins/slide/slide.h | 2 +- src/plugins/slideback/motionmanager.h | 4 ++-- src/plugins/slideback/slideback.cpp | 12 +++++------ src/plugins/slideback/slideback.h | 10 +++++----- src/plugins/slidingpopups/slidingpopups.cpp | 2 +- src/scripting/scriptedeffect.cpp | 2 +- 12 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/effect/effects.cpp b/src/effect/effects.cpp index 0f2a72a731..00c5b9b346 100644 --- a/src/effect/effects.cpp +++ b/src/effect/effects.cpp @@ -904,10 +904,10 @@ EffectWindow *EffectsHandler::findWindow(const QUuid &id) const return nullptr; } -EffectWindowList EffectsHandler::stackingOrder() const +QList EffectsHandler::stackingOrder() const { QList list = workspace()->stackingOrder(); - EffectWindowList ret; + QList ret; for (Window *t : list) { if (EffectWindow *w = t->effectWindow()) { ret.append(w); @@ -937,11 +937,11 @@ void EffectsHandler::setTabBoxWindow(EffectWindow *w) #endif } -EffectWindowList EffectsHandler::currentTabBoxWindowList() const +QList EffectsHandler::currentTabBoxWindowList() const { #if KWIN_BUILD_TABBOX const auto clients = workspace()->tabbox()->currentClientList(); - EffectWindowList ret; + QList ret; ret.reserve(clients.size()); std::transform(std::cbegin(clients), std::cend(clients), std::back_inserter(ret), @@ -950,7 +950,7 @@ EffectWindowList EffectsHandler::currentTabBoxWindowList() const }); return ret; #else - return EffectWindowList(); + return QList(); #endif } @@ -2021,10 +2021,10 @@ QWindow *EffectWindow::internalWindow() const } template -EffectWindowList getMainWindows(T *c) +QList getMainWindows(T *c) { const auto mainwindows = c->mainWindows(); - EffectWindowList ret; + QList ret; ret.reserve(mainwindows.size()); std::transform(std::cbegin(mainwindows), std::cend(mainwindows), std::back_inserter(ret), @@ -2034,7 +2034,7 @@ EffectWindowList getMainWindows(T *c) return ret; } -EffectWindowList EffectWindow::mainWindows() const +QList EffectWindow::mainWindows() const { return getMainWindows(d->m_window); } @@ -2108,10 +2108,10 @@ EffectWindowGroup::~EffectWindowGroup() { } -EffectWindowList EffectWindowGroup::members() const +QList EffectWindowGroup::members() const { const auto memberList = m_group->members(); - EffectWindowList ret; + QList ret; ret.reserve(memberList.size()); std::transform(std::cbegin(memberList), std::cend(memberList), std::back_inserter(ret), [](auto window) { return window->effectWindow(); diff --git a/src/effect/effects.h b/src/effect/effects.h index a2d3178da2..78317f9166 100644 --- a/src/effect/effects.h +++ b/src/effect/effects.h @@ -81,7 +81,6 @@ class WorkspaceScene; class VirtualDesktop; typedef QPair EffectPair; -typedef QList EffectWindowList; /** * EffectWindow::setData() and EffectWindow::data() global roles. @@ -136,7 +135,7 @@ class KWIN_EXPORT EffectsHandler : public QObject * if used manually. */ Q_PROPERTY(qreal animationTimeFactor READ animationTimeFactor) - Q_PROPERTY(KWin::EffectWindowList stackingOrder READ stackingOrder) + Q_PROPERTY(QList stackingOrder READ stackingOrder) /** * Whether window decorations use the alpha channel. */ @@ -440,12 +439,12 @@ public: * @since 5.16 */ Q_SCRIPTABLE KWin::EffectWindow *findWindow(const QUuid &id) const; - EffectWindowList stackingOrder() const; + QList stackingOrder() const; // window will be temporarily painted as if being at the top of the stack Q_SCRIPTABLE void setElevatedWindow(KWin::EffectWindow *w, bool set); void setTabBoxWindow(EffectWindow *); - EffectWindowList currentTabBoxWindowList() const; + QList currentTabBoxWindowList() const; void refTabBox(); void unrefTabBox(); void closeTabBox(); @@ -1638,7 +1637,7 @@ public: bool isModal() const; Q_SCRIPTABLE KWin::EffectWindow *findModal(); Q_SCRIPTABLE KWin::EffectWindow *transientFor(); - Q_SCRIPTABLE KWin::EffectWindowList mainWindows() const; + Q_SCRIPTABLE QList mainWindows() const; /** * Returns whether the window should be excluded from window switching effects. @@ -2056,7 +2055,7 @@ public: explicit EffectWindowGroup(Group *group); virtual ~EffectWindowGroup(); - EffectWindowList members() const; + QList members() const; private: Group *m_group; @@ -2083,6 +2082,5 @@ inline void EffectWindow::addLayerRepaint(int x, int y, int w, int h) } // namespace Q_DECLARE_METATYPE(KWin::EffectWindow *) -Q_DECLARE_METATYPE(KWin::EffectWindowList) /** @} */ diff --git a/src/plugins/backgroundcontrast/contrast.cpp b/src/plugins/backgroundcontrast/contrast.cpp index d04b95268b..fbe638a617 100644 --- a/src/plugins/backgroundcontrast/contrast.cpp +++ b/src/plugins/backgroundcontrast/contrast.cpp @@ -70,7 +70,7 @@ ContrastEffect::ContrastEffect() }); // Fetch the contrast regions for all windows - const EffectWindowList windowList = effects->stackingOrder(); + const QList windowList = effects->stackingOrder(); for (EffectWindow *window : windowList) { slotWindowAdded(window); } @@ -92,7 +92,7 @@ void ContrastEffect::slotScreenGeometryChanged() return; } - const EffectWindowList windowList = effects->stackingOrder(); + const QList windowList = effects->stackingOrder(); for (EffectWindow *window : windowList) { updateContrastRegion(window); } diff --git a/src/plugins/blendchanges/blendchanges.cpp b/src/plugins/blendchanges/blendchanges.cpp index 1c11d64544..ce75c67f9b 100644 --- a/src/plugins/blendchanges/blendchanges.cpp +++ b/src/plugins/blendchanges/blendchanges.cpp @@ -44,7 +44,7 @@ void KWin::BlendChanges::start(int delay) return; } - const EffectWindowList allWindows = effects->stackingOrder(); + const QList allWindows = effects->stackingOrder(); for (auto window : allWindows) { if (!window->isFullScreen()) { redirect(window); @@ -71,7 +71,7 @@ void BlendChanges::postPaintScreen() m_timeline.reset(); m_state = Off; - const EffectWindowList allWindows = effects->stackingOrder(); + const QList allWindows = effects->stackingOrder(); for (auto window : allWindows) { unredirect(window); } diff --git a/src/plugins/highlightwindow/highlightwindow.cpp b/src/plugins/highlightwindow/highlightwindow.cpp index 2afc067993..9f6e84d2bf 100644 --- a/src/plugins/highlightwindow/highlightwindow.cpp +++ b/src/plugins/highlightwindow/highlightwindow.cpp @@ -159,7 +159,7 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow *w, long a, EffectWi void HighlightWindowEffect::prepareHighlighting() { - const EffectWindowList windows = effects->stackingOrder(); + const QList windows = effects->stackingOrder(); for (EffectWindow *window : windows) { if (!isHighlightWindow(window)) { continue; @@ -174,7 +174,7 @@ void HighlightWindowEffect::prepareHighlighting() void HighlightWindowEffect::finishHighlighting() { - const EffectWindowList windows = effects->stackingOrder(); + const QList windows = effects->stackingOrder(); for (EffectWindow *window : windows) { if (isHighlightWindow(window)) { startRevertAnimation(window); diff --git a/src/plugins/slide/slide.cpp b/src/plugins/slide/slide.cpp index e05ff44fdb..3f05dd233d 100644 --- a/src/plugins/slide/slide.cpp +++ b/src/plugins/slide/slide.cpp @@ -336,7 +336,7 @@ void SlideEffect::finishedSwitching() if (m_state == State::Inactive) { return; } - const EffectWindowList windows = effects->stackingOrder(); + const QList windows = effects->stackingOrder(); for (EffectWindow *w : windows) { w->setData(WindowForceBackgroundContrastRole, QVariant()); w->setData(WindowForceBlurRole, QVariant()); diff --git a/src/plugins/slide/slide.h b/src/plugins/slide/slide.h index 968372d1ff..f80e7d62c7 100644 --- a/src/plugins/slide/slide.h +++ b/src/plugins/slide/slide.h @@ -128,7 +128,7 @@ private: EffectWindowVisibleRef visibilityRef; }; - EffectWindowList m_elevatedWindows; + QList m_elevatedWindows; QHash m_windowData; }; diff --git a/src/plugins/slideback/motionmanager.h b/src/plugins/slideback/motionmanager.h index 5876098f74..ad04bc9db3 100644 --- a/src/plugins/slideback/motionmanager.h +++ b/src/plugins/slideback/motionmanager.h @@ -167,7 +167,7 @@ public: /** * Register a list of windows for managing. */ - inline void manage(const EffectWindowList &list) + inline void manage(const QList &list) { for (int i = 0; i < list.size(); i++) { manage(list.at(i)); @@ -257,7 +257,7 @@ public: /** * Return a list of all currently registered windows. */ - inline EffectWindowList managedWindows() const + inline QList managedWindows() const { return m_managedWindows.keys(); } diff --git a/src/plugins/slideback/slideback.cpp b/src/plugins/slideback/slideback.cpp index b0dbecb591..399b130b08 100644 --- a/src/plugins/slideback/slideback.cpp +++ b/src/plugins/slideback/slideback.cpp @@ -36,8 +36,8 @@ void SlideBackEffect::slotStackingOrderChanged() return; } - EffectWindowList newStackingOrder = effects->stackingOrder(), - usableNewStackingOrder = usableWindows(newStackingOrder); + QList newStackingOrder = effects->stackingOrder(), + usableNewStackingOrder = usableWindows(newStackingOrder); if (usableNewStackingOrder == usableOldStackingOrder || usableNewStackingOrder.isEmpty()) { oldStackingOrder = newStackingOrder; usableOldStackingOrder = usableNewStackingOrder; @@ -142,7 +142,7 @@ void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; } - const EffectWindowList windows = effects->stackingOrder(); + const QList windows = effects->stackingOrder(); for (auto *w : windows) { w->setData(WindowForceBlurRole, QVariant(true)); } @@ -192,7 +192,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow *w) // If we are still intersecting with the upmostWindow it is moving. slide to somewhere else // restore the stacking order of all windows not intersecting any more except panels if (coveringWindows.contains(w)) { - EffectWindowList tmpList; + QList tmpList; for (EffectWindow *tmp : std::as_const(elevatedList)) { QRect elevatedGeometry = tmp->frameGeometry().toRect(); if (motionManager.isManaging(tmp)) { @@ -311,9 +311,9 @@ bool SlideBackEffect::intersects(EffectWindow *windowUnder, const QRect &windowO return windowUnderGeometry.intersects(windowOverGeometry); } -EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList &allWindows) +QList SlideBackEffect::usableWindows(const QList &allWindows) { - EffectWindowList retList; + QList retList; auto isWindowVisible = [](const EffectWindow *window) { return window && effects->virtualScreenGeometry().intersects(window->frameGeometry().toAlignedRect()); }; diff --git a/src/plugins/slideback/slideback.h b/src/plugins/slideback/slideback.h index ab695b8454..0f48438e56 100644 --- a/src/plugins/slideback/slideback.h +++ b/src/plugins/slideback/slideback.h @@ -46,10 +46,10 @@ public Q_SLOTS: private: WindowMotionManager motionManager; - EffectWindowList usableOldStackingOrder; - EffectWindowList oldStackingOrder; - EffectWindowList coveringWindows; - EffectWindowList elevatedList; + QList usableOldStackingOrder; + QList oldStackingOrder; + QList coveringWindows; + QList elevatedList; EffectWindow *m_justMapped, *m_upmostWindow; QHash destinationList; int m_tabboxActive; @@ -59,7 +59,7 @@ private: QRect getSlideDestination(const QRect &windowUnderGeometry, const QRect &windowOverGeometry); bool isWindowUsable(EffectWindow *w); bool intersects(EffectWindow *windowUnder, const QRect &windowOverGeometry); - EffectWindowList usableWindows(const EffectWindowList &allWindows); + QList usableWindows(const QList &allWindows); QRect getModalGroupGeometry(EffectWindow *w); void windowRaised(EffectWindow *w); }; diff --git a/src/plugins/slidingpopups/slidingpopups.cpp b/src/plugins/slidingpopups/slidingpopups.cpp index b4018c5069..a399b14bba 100644 --- a/src/plugins/slidingpopups/slidingpopups.cpp +++ b/src/plugins/slidingpopups/slidingpopups.cpp @@ -67,7 +67,7 @@ SlidingPopupsEffect::SlidingPopupsEffect() reconfigure(ReconfigureAll); - const EffectWindowList windows = effects->stackingOrder(); + const QList windows = effects->stackingOrder(); for (EffectWindow *window : windows) { setupSlideData(window); } diff --git a/src/scripting/scriptedeffect.cpp b/src/scripting/scriptedeffect.cpp index 7a8e194042..46fe98e761 100644 --- a/src/scripting/scriptedeffect.cpp +++ b/src/scripting/scriptedeffect.cpp @@ -211,7 +211,7 @@ ScriptedEffect::~ScriptedEffect() = default; bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript) { qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType>(); QFile scriptFile(pathToScript); if (!scriptFile.open(QIODevice::ReadOnly)) {