core: move all shared_ptrs from the STL to hyprutils (#9143)

This commit is contained in:
Vaxry 2025-01-23 21:55:41 +01:00 committed by GitHub
parent ae403e6a05
commit 0a1ae48a9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
152 changed files with 297 additions and 349 deletions

View file

@ -1,7 +1,7 @@
#include <re2/re2.h>
#include "LayerRule.hpp"
#include <unordered_set>
#include <algorithm>
#include <re2/re2.h>
#include "../debug/Log.hpp"
static const auto RULES = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};

View file

@ -32,7 +32,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->szNamespace = resource->layerNamespace;
pLS->layer = resource->current.layer;
pLS->popupHead = std::make_unique<CPopup>(pLS);
pLS->popupHead = makeUnique<CPopup>(pLS);
pLS->monitor = pMonitor;
pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS);

View file

@ -59,7 +59,7 @@ class CLayerSurface {
CBox geometry = {0, 0, 0, 0};
Vector2D position;
std::string szNamespace = "";
std::unique_ptr<CPopup> popupHead;
UP<CPopup> popupHead;
void onDestroy();
void onMap();

View file

@ -89,7 +89,7 @@ void CPopup::onMap() {
g_pInputManager->simulateMouseMovement();
m_pSubsurfaceHead = std::make_unique<CSubsurface>(this);
m_pSubsurfaceHead = makeUnique<CSubsurface>(this);
//unconstrain();
sendScale();

View file

@ -1,9 +1,9 @@
#pragma once
#include <vector>
#include <memory>
#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<SP<CPopup>> m_vChildren;
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
std::vector<SP<CPopup>> m_vChildren;
UP<CSubsurface> m_pSubsurfaceHead;
struct {
CHyprSignalListener newPopup;

View file

@ -1,12 +1,13 @@
#include "Rule.hpp"
#include <re2/re2.h>
#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<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
regex = makeUnique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
// TODO: maybe pop an error?
if (!regex->ok())

View file

@ -1,6 +1,6 @@
#pragma once
#include <memory>
#include <hyprutils/memory/UniquePtr.hpp>
//NOLINTNEXTLINE
namespace re2 {
@ -16,6 +16,6 @@ class CRuleRegexContainer {
bool passes(const std::string& str) const;
private:
std::unique_ptr<re2::RE2> regex;
bool negative = false;
Hyprutils::Memory::CUniquePointer<re2::RE2> regex;
bool negative = false;
};

View file

@ -126,9 +126,9 @@ void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
CSubsurface* PSUBSURFACE = nullptr;
if (!m_pWindowParent.expired())
PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pWindowParent.lock())).get();
PSUBSURFACE = m_vChildren.emplace_back(makeUnique<CSubsurface>(pSubsurface, m_pWindowParent.lock())).get();
else if (m_pPopupParent)
PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pPopupParent)).get();
PSUBSURFACE = m_vChildren.emplace_back(makeUnique<CSubsurface>(pSubsurface, m_pPopupParent)).get();
ASSERT(PSUBSURFACE);

View file

@ -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<std::unique_ptr<CSubsurface>> m_vChildren;
std::vector<UP<CSubsurface>> m_vChildren;
bool m_bInert = false;
bool m_bInert = false;
void initSignals();
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
void checkSiblingDamage();
void initSignals();
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
void checkSiblingDamage();
};

View file

@ -47,8 +47,8 @@ PHLWINDOW CWindow::create(SP<CXWaylandSurface> 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<CHyprDropShadowDecoration>(pWindow));
pWindow->addWindowDeco(std::make_unique<CHyprBorderDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprDropShadowDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprBorderDecoration>(pWindow));
return pWindow;
}
@ -70,8 +70,8 @@ PHLWINDOW CWindow::create(SP<CXDGSurfaceResource> 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<CHyprDropShadowDecoration>(pWindow));
pWindow->addWindowDeco(std::make_unique<CHyprBorderDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprDropShadowDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprBorderDecoration>(pWindow));
pWindow->m_pWLSurface->assign(pWindow->m_pXDGSurface->surface.lock(), pWindow);
@ -296,7 +296,7 @@ void CWindow::updateWindowDecos() {
}
}
void CWindow::addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco) {
void CWindow::addWindowDeco(UP<IHyprWindowDecoration> 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<CSubsurface>(m_pSelf.lock());
m_pPopupHead = std::make_unique<CPopup>(m_pSelf.lock());
m_pSubsurfaceHead = makeUnique<CSubsurface>(m_pSelf.lock());
m_pPopupHead = makeUnique<CPopup>(m_pSelf.lock());
}
void CWindow::onBorderAngleAnimEnd(WP<CBaseAnimatedVariable> pav) {
@ -870,7 +870,7 @@ void CWindow::createGroup() {
m_sGroupData.locked = false;
m_sGroupData.deny = false;
addWindowDeco(std::make_unique<CHyprGroupBarDecoration>(m_pSelf.lock()));
addWindowDeco(makeUnique<CHyprGroupBarDecoration>(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<CHyprGroupBarDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprGroupBarDecoration>(pWindow));
if (!pWindow->m_sGroupData.pNextWindow.lock()) {
BEGINAT->m_sGroupData.pNextWindow = pWindow;

View file

@ -296,8 +296,8 @@ class CWindow {
uint64_t m_eSuppressedEvents = SUPPRESS_NONE;
// desktop components
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
std::unique_ptr<CPopup> m_pPopupHead;
UP<CSubsurface> m_pSubsurfaceHead;
UP<CPopup> m_pPopupHead;
// Animated border
CGradientValueData m_cRealBorderColor = {0};
@ -328,14 +328,14 @@ class CWindow {
// Window decorations
// TODO: make this a SP.
std::vector<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
std::vector<UP<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
// Special render data, rules, etc
SWindowData m_sWindowData;
// Transformers
std::vector<std::unique_ptr<IWindowTransformer>> m_vTransformers;
std::vector<UP<IWindowTransformer>> m_vTransformers;
// for alpha
PHLANIMVAR<float> m_fActiveInactiveAlpha;
@ -396,7 +396,7 @@ class CWindow {
SBoxExtents getFullWindowExtents();
CBox getWindowBoxUnified(uint64_t props);
CBox getWindowIdealBoundingBoxIgnoreReserved();
void addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco);
void addWindowDeco(UP<IHyprWindowDecoration> deco);
void updateWindowDecos();
void removeWindowDeco(IHyprWindowDecoration* deco);
void uncacheWindowDecos();