diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-04-27 12:43:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-27 12:43:12 +0100 |
| commit | bca7804bb6e1bf5ce5a99b9ae4806be25e36993c (patch) | |
| tree | ebd3a578de1dfe11b54f9440cfc3a408ffa6a620 /src/helpers | |
| parent | 25aec3ac8ce65ed224f025f8f6dfef73780577a4 (diff) | |
internal: Window storage rework - part 1 (#5762)
* Window storage rework - part 1
* format
* remove useless include
* fix pch
* format
* fix crash in dwindle
* fix vram leak
* prefer .expired() for bool checks
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/AnimatedVariable.cpp | 2 | ||||
| -rw-r--r-- | src/helpers/AnimatedVariable.hpp | 12 | ||||
| -rw-r--r-- | src/helpers/Monitor.cpp | 12 | ||||
| -rw-r--r-- | src/helpers/Monitor.hpp | 2 | ||||
| -rw-r--r-- | src/helpers/WLClasses.hpp | 4 | ||||
| -rw-r--r-- | src/helpers/WLListener.cpp | 2 | ||||
| -rw-r--r-- | src/helpers/signal/Signal.cpp | 2 |
7 files changed, 18 insertions, 18 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp index 65206af0..0d6f15aa 100644 --- a/src/helpers/AnimatedVariable.cpp +++ b/src/helpers/AnimatedVariable.cpp @@ -6,7 +6,7 @@ CBaseAnimatedVariable::CBaseAnimatedVariable(ANIMATEDVARTYPE type) : m_Type(type ; // dummy var } -void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy) { +void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy) { m_eDamagePolicy = policy; m_pConfig = pAnimConfig; m_pWindow = pWindow; diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index 4c24f642..02849306 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -6,7 +6,7 @@ #include <type_traits> #include "Vector2D.hpp" #include "Color.hpp" -#include "../macros.hpp" +#include "../defines.hpp" #include "../debug/Log.hpp" #include "../desktop/DesktopTypes.hpp" @@ -68,7 +68,7 @@ concept Animable = OneOf<T, Vector2D, float, CColor>; class CBaseAnimatedVariable { public: CBaseAnimatedVariable(ANIMATEDVARTYPE type); - void create(SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy); + void create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, SLayerSurface* pLayer, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy); void create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy); @@ -140,12 +140,12 @@ class CBaseAnimatedVariable { m_bRemoveEndAfterRan = false; } - CWindow* getWindow() { - return (CWindow*)m_pWindow; + PHLWINDOW getWindow() { + return m_pWindow.lock(); } protected: - void* m_pWindow = nullptr; + PHLWINDOWREF m_pWindow; std::weak_ptr<CWorkspace> m_pWorkspace; void* m_pLayer = nullptr; @@ -208,7 +208,7 @@ class CAnimatedVariable : public CBaseAnimatedVariable { public: CAnimatedVariable() : CBaseAnimatedVariable(typeToANIMATEDVARTYPE<VarType>) {} // dummy var - void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, CWindow* pWindow, AVARDAMAGEPOLICY policy) { + void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy) { create(pAnimConfig, pWindow, policy); m_Value = value; m_Goal = value; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index f7d2274c..ffa8b7d8 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -303,8 +303,8 @@ void CMonitor::onDisconnect(bool destroy) { w->startAnim(true, true, true); } } else { - g_pCompositor->m_pLastFocus = nullptr; - g_pCompositor->m_pLastWindow = nullptr; + g_pCompositor->m_pLastFocus = nullptr; + g_pCompositor->m_pLastWindow.reset(); g_pCompositor->m_pLastMonitor = nullptr; } @@ -577,9 +577,9 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo } if (!noFocus && !g_pCompositor->m_pLastMonitor->activeSpecialWorkspace && - !(g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bPinned && g_pCompositor->m_pLastWindow->m_iMonitorID == ID)) { + !(g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow.lock()->m_bPinned && g_pCompositor->m_pLastWindow.lock()->m_iMonitorID == ID)) { static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse"); - CWindow* pWindow = pWorkspace->getLastFocusedWindow(); + auto pWindow = pWorkspace->getLastFocusedWindow(); if (!pWindow) { if (*PFOLLOWMOUSE == 1) @@ -635,7 +635,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); - if (!(g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bPinned && g_pCompositor->m_pLastWindow->m_iMonitorID == ID)) { + if (!(g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow.lock()->m_bPinned && g_pCompositor->m_pLastWindow.lock()->m_iMonitorID == ID)) { if (const auto PLAST = activeWorkspace->getLastFocusedWindow(); PLAST) g_pCompositor->focusWindow(PLAST); else @@ -703,7 +703,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); - if (!(g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bPinned && g_pCompositor->m_pLastWindow->m_iMonitorID == ID)) { + if (!(g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow.lock()->m_bPinned && g_pCompositor->m_pLastWindow.lock()->m_iMonitorID == ID)) { if (const auto PLAST = pWorkspace->getLastFocusedWindow(); PLAST) g_pCompositor->focusWindow(PLAST); else diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 75178836..4d1e1c70 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -118,7 +118,7 @@ class CMonitor { std::vector<CMonitor*> mirrors; // for tearing - CWindow* solitaryClient = nullptr; + PHLWINDOWREF solitaryClient; struct { bool canTear = false; diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 3ea6e71e..8066baf9 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -108,9 +108,9 @@ struct SRenderData { bool squishOversized = true; // for calculating UV - CWindow* pWindow = nullptr; + PHLWINDOW pWindow; - bool popup = false; + bool popup = false; }; struct SExtensionFindingData { diff --git a/src/helpers/WLListener.cpp b/src/helpers/WLListener.cpp index f499b929..978ff034 100644 --- a/src/helpers/WLListener.cpp +++ b/src/helpers/WLListener.cpp @@ -12,7 +12,7 @@ void handleWrapped(wl_listener* listener, void* data) { try { pWrap->m_pSelf->emit(data); - } catch (std::exception& e) { Debug::log(ERR, "Listener {} timed out and was killed by Watchdog!!!", (uintptr_t)listener); } + } catch (std::exception& e) { Debug::log(ERR, "Listener {} threw or timed out and was killed by Watchdog!!! This is bad. what(): {}", (uintptr_t)listener, e.what()); } if (g_pWatchdog) g_pWatchdog->endWatching(); diff --git a/src/helpers/signal/Signal.cpp b/src/helpers/signal/Signal.cpp index a8adc275..204aaf00 100644 --- a/src/helpers/signal/Signal.cpp +++ b/src/helpers/signal/Signal.cpp @@ -12,7 +12,7 @@ void CSignal::emit(std::any data) { } if (dirty) - std::erase_if(m_vListeners, [](const auto& other) { return !other.lock(); }); + std::erase_if(m_vListeners, [](const auto& other) { return other.expired(); }); } CHyprSignalListener CSignal::registerListener(std::function<void(std::any)> handler) { |
