From 0a1ae48a9fd6eb76baad27de98c00f653a55e4ac Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:55:41 +0100 Subject: core: move all shared_ptrs from the STL to hyprutils (#9143) --- src/desktop/LayerRule.cpp | 2 +- src/desktop/LayerSurface.cpp | 2 +- src/desktop/LayerSurface.hpp | 2 +- src/desktop/Popup.cpp | 2 +- src/desktop/Popup.hpp | 6 +++--- src/desktop/Rule.cpp | 5 +++-- src/desktop/Rule.hpp | 6 +++--- src/desktop/Subsurface.cpp | 4 ++-- src/desktop/Subsurface.hpp | 16 ++++++++-------- src/desktop/Window.cpp | 18 +++++++++--------- src/desktop/Window.hpp | 12 ++++++------ 11 files changed, 38 insertions(+), 37 deletions(-) (limited to 'src/desktop') diff --git a/src/desktop/LayerRule.cpp b/src/desktop/LayerRule.cpp index 23371947..791a557e 100644 --- a/src/desktop/LayerRule.cpp +++ b/src/desktop/LayerRule.cpp @@ -1,7 +1,7 @@ +#include #include "LayerRule.hpp" #include #include -#include #include "../debug/Log.hpp" static const auto RULES = std::unordered_set{"noanim", "blur", "blurpopups", "dimaround"}; diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index c572f6b2..dd30aa7c 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -32,7 +32,7 @@ PHLLS CLayerSurface::create(SP resource) { pLS->szNamespace = resource->layerNamespace; pLS->layer = resource->current.layer; - pLS->popupHead = std::make_unique(pLS); + pLS->popupHead = makeUnique(pLS); pLS->monitor = pMonitor; pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS); diff --git a/src/desktop/LayerSurface.hpp b/src/desktop/LayerSurface.hpp index 591dfd99..ab259733 100644 --- a/src/desktop/LayerSurface.hpp +++ b/src/desktop/LayerSurface.hpp @@ -59,7 +59,7 @@ class CLayerSurface { CBox geometry = {0, 0, 0, 0}; Vector2D position; std::string szNamespace = ""; - std::unique_ptr popupHead; + UP popupHead; void onDestroy(); void onMap(); diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index ce6ab9a0..831619a5 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -89,7 +89,7 @@ void CPopup::onMap() { g_pInputManager->simulateMouseMovement(); - m_pSubsurfaceHead = std::make_unique(this); + m_pSubsurfaceHead = makeUnique(this); //unconstrain(); sendScale(); diff --git a/src/desktop/Popup.hpp b/src/desktop/Popup.hpp index e9b3e0f0..2b7b4e82 100644 --- a/src/desktop/Popup.hpp +++ b/src/desktop/Popup.hpp @@ -1,9 +1,9 @@ #pragma once #include -#include #include "Subsurface.hpp" #include "../helpers/signal/Signal.hpp" +#include "../helpers/memory/Memory.hpp" class CXDGPopupResource; @@ -61,8 +61,8 @@ class CPopup { bool m_bInert = false; // - std::vector> m_vChildren; - std::unique_ptr m_pSubsurfaceHead; + std::vector> m_vChildren; + UP m_pSubsurfaceHead; struct { CHyprSignalListener newPopup; diff --git a/src/desktop/Rule.cpp b/src/desktop/Rule.cpp index ae280642..aa87a483 100644 --- a/src/desktop/Rule.cpp +++ b/src/desktop/Rule.cpp @@ -1,12 +1,13 @@ -#include "Rule.hpp" #include +#include "../helpers/memory/Memory.hpp" +#include "Rule.hpp" #include "../debug/Log.hpp" CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) { const bool NEGATIVE = regex_.starts_with("negative:"); negative = NEGATIVE; - regex = std::make_unique(NEGATIVE ? regex_.substr(9) : regex_); + regex = makeUnique(NEGATIVE ? regex_.substr(9) : regex_); // TODO: maybe pop an error? if (!regex->ok()) diff --git a/src/desktop/Rule.hpp b/src/desktop/Rule.hpp index 4b178ee8..858b4ded 100644 --- a/src/desktop/Rule.hpp +++ b/src/desktop/Rule.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include //NOLINTNEXTLINE namespace re2 { @@ -16,6 +16,6 @@ class CRuleRegexContainer { bool passes(const std::string& str) const; private: - std::unique_ptr regex; - bool negative = false; + Hyprutils::Memory::CUniquePointer regex; + bool negative = false; }; \ No newline at end of file diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index 26638f7a..9cdf3685 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -126,9 +126,9 @@ void CSubsurface::onNewSubsurface(SP pSubsurface) { CSubsurface* PSUBSURFACE = nullptr; if (!m_pWindowParent.expired()) - PSUBSURFACE = m_vChildren.emplace_back(std::make_unique(pSubsurface, m_pWindowParent.lock())).get(); + PSUBSURFACE = m_vChildren.emplace_back(makeUnique(pSubsurface, m_pWindowParent.lock())).get(); else if (m_pPopupParent) - PSUBSURFACE = m_vChildren.emplace_back(std::make_unique(pSubsurface, m_pPopupParent)).get(); + PSUBSURFACE = m_vChildren.emplace_back(makeUnique(pSubsurface, m_pPopupParent)).get(); ASSERT(PSUBSURFACE); diff --git a/src/desktop/Subsurface.hpp b/src/desktop/Subsurface.hpp index 7829c489..aacbad91 100644 --- a/src/desktop/Subsurface.hpp +++ b/src/desktop/Subsurface.hpp @@ -48,16 +48,16 @@ class CSubsurface { Vector2D m_vLastSize = {}; // if nullptr, means it's a dummy node - CSubsurface* m_pParent = nullptr; + CSubsurface* m_pParent = nullptr; - PHLWINDOWREF m_pWindowParent; - CPopup* m_pPopupParent = nullptr; + PHLWINDOWREF m_pWindowParent; + CPopup* m_pPopupParent = nullptr; - std::vector> m_vChildren; + std::vector> m_vChildren; - bool m_bInert = false; + bool m_bInert = false; - void initSignals(); - void initExistingSubsurfaces(SP pSurface); - void checkSiblingDamage(); + void initSignals(); + void initExistingSubsurfaces(SP pSurface); + void checkSiblingDamage(); }; \ No newline at end of file diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 829f4e2e..fb5904be 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -47,8 +47,8 @@ PHLWINDOW CWindow::create(SP surface) { g_pAnimationManager->createAnimation(0.f, pWindow->m_fMovingToWorkspaceAlpha, g_pConfigManager->getAnimationPropertyConfig("fadeOut"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(0.f, pWindow->m_fMovingFromWorkspaceAlpha, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); - pWindow->addWindowDeco(std::make_unique(pWindow)); - pWindow->addWindowDeco(std::make_unique(pWindow)); + pWindow->addWindowDeco(makeUnique(pWindow)); + pWindow->addWindowDeco(makeUnique(pWindow)); return pWindow; } @@ -70,8 +70,8 @@ PHLWINDOW CWindow::create(SP resource) { g_pAnimationManager->createAnimation(0.f, pWindow->m_fMovingToWorkspaceAlpha, g_pConfigManager->getAnimationPropertyConfig("fadeOut"), pWindow, AVARDAMAGE_ENTIRE); g_pAnimationManager->createAnimation(0.f, pWindow->m_fMovingFromWorkspaceAlpha, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), pWindow, AVARDAMAGE_ENTIRE); - pWindow->addWindowDeco(std::make_unique(pWindow)); - pWindow->addWindowDeco(std::make_unique(pWindow)); + pWindow->addWindowDeco(makeUnique(pWindow)); + pWindow->addWindowDeco(makeUnique(pWindow)); pWindow->m_pWLSurface->assign(pWindow->m_pXDGSurface->surface.lock(), pWindow); @@ -296,7 +296,7 @@ void CWindow::updateWindowDecos() { } } -void CWindow::addWindowDeco(std::unique_ptr deco) { +void CWindow::addWindowDeco(UP deco) { m_dWindowDecorations.emplace_back(std::move(deco)); g_pDecorationPositioner->forceRecalcFor(m_pSelf.lock()); updateWindowDecos(); @@ -567,8 +567,8 @@ void CWindow::onMap() { if (m_bIsX11) return; - m_pSubsurfaceHead = std::make_unique(m_pSelf.lock()); - m_pPopupHead = std::make_unique(m_pSelf.lock()); + m_pSubsurfaceHead = makeUnique(m_pSelf.lock()); + m_pPopupHead = makeUnique(m_pSelf.lock()); } void CWindow::onBorderAngleAnimEnd(WP pav) { @@ -870,7 +870,7 @@ void CWindow::createGroup() { m_sGroupData.locked = false; m_sGroupData.deny = false; - addWindowDeco(std::make_unique(m_pSelf.lock())); + addWindowDeco(makeUnique(m_pSelf.lock())); if (m_pWorkspace) { m_pWorkspace->updateWindows(); @@ -1052,7 +1052,7 @@ void CWindow::insertWindowToGroup(PHLWINDOW pWindow) { const auto ENDAT = m_sGroupData.pNextWindow.lock(); if (!pWindow->getDecorationByType(DECORATION_GROUPBAR)) - pWindow->addWindowDeco(std::make_unique(pWindow)); + pWindow->addWindowDeco(makeUnique(pWindow)); if (!pWindow->m_sGroupData.pNextWindow.lock()) { BEGINAT->m_sGroupData.pNextWindow = pWindow; diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index ebda235c..5b4ad654 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -296,8 +296,8 @@ class CWindow { uint64_t m_eSuppressedEvents = SUPPRESS_NONE; // desktop components - std::unique_ptr m_pSubsurfaceHead; - std::unique_ptr m_pPopupHead; + UP m_pSubsurfaceHead; + UP m_pPopupHead; // Animated border CGradientValueData m_cRealBorderColor = {0}; @@ -328,14 +328,14 @@ class CWindow { // Window decorations // TODO: make this a SP. - std::vector> m_dWindowDecorations; - std::vector m_vDecosToRemove; + std::vector> m_dWindowDecorations; + std::vector m_vDecosToRemove; // Special render data, rules, etc SWindowData m_sWindowData; // Transformers - std::vector> m_vTransformers; + std::vector> m_vTransformers; // for alpha PHLANIMVAR m_fActiveInactiveAlpha; @@ -396,7 +396,7 @@ class CWindow { SBoxExtents getFullWindowExtents(); CBox getWindowBoxUnified(uint64_t props); CBox getWindowIdealBoundingBoxIgnoreReserved(); - void addWindowDeco(std::unique_ptr deco); + void addWindowDeco(UP deco); void updateWindowDecos(); void removeWindowDeco(IHyprWindowDecoration* deco); void uncacheWindowDecos(); -- cgit v1.2.3