From 894ae2d74217f4c37653022d855d00fd46c39457 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 28 May 2022 23:43:11 +0200 Subject: [PATCH] Use C++-styled pointers for decorations --- src/Window.cpp | 3 --- src/Window.hpp | 2 +- src/layout/DwindleLayout.cpp | 4 ++-- src/render/decorations/CHyprGroupBarDecoration.cpp | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index cc76aed2..5bb1738e 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -13,7 +13,4 @@ CWindow::~CWindow() { g_pCompositor->m_pLastFocus = nullptr; g_pCompositor->m_pLastWindow = nullptr; } - - for (auto& wd : m_dWindowDecorations) - delete wd; } \ No newline at end of file diff --git a/src/Window.hpp b/src/Window.hpp index 0dd105bb..8977c7ff 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -91,7 +91,7 @@ public: bool m_bHidden = false; // Window decorations - std::deque m_dWindowDecorations; + std::deque> m_dWindowDecorations; // Special render data, rules, etc SWindowSpecialRenderData m_sSpecialRenderData; diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 0f41265b..8117622c 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -277,7 +277,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { // means we opened on a group // add the group deco - pWindow->m_dWindowDecorations.emplace_back(new CHyprGroupBarDecoration(pWindow)); + pWindow->m_dWindowDecorations.emplace_back(std::make_unique(pWindow)); PNODE->pGroupParent = OPENINGON->pGroupParent; PNODE->pGroupParent->groupMembers.push_back(PNODE); @@ -733,7 +733,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) { c->pGroupParent = PPARENT; c->pWindow->m_cRealBorderColor = GROUPINACTIVEBORDERCOL; - c->pWindow->m_dWindowDecorations.push_back(new CHyprGroupBarDecoration(c->pWindow)); + c->pWindow->m_dWindowDecorations.push_back(std::make_unique(c->pWindow)); if (c->pWindow == g_pCompositor->m_pLastWindow) c->pWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")); diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index a677638c..25d74065 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -37,9 +37,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { if (g_pLayoutManager->getCurrentLayout()->getLayoutName() != "dwindle") { // ???? for (auto it = pWindow->m_dWindowDecorations.begin(); it != pWindow->m_dWindowDecorations.end(); it++) { - if ((*it) == this) { + if (it->get() == this) { pWindow->m_dWindowDecorations.erase(it); - delete this; return; } } @@ -56,9 +55,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { if (m_dwGroupMembers.size() == 0) { // remove for (auto it = pWindow->m_dWindowDecorations.begin(); it != pWindow->m_dWindowDecorations.end(); it++) { - if ((*it) == this) { + if (it->get() == this) { pWindow->m_dWindowDecorations.erase(it); - delete this; return; } }