diff --git a/src/config/ConfigValue.hpp b/src/config/ConfigValue.hpp index 72accd67..fc8abb4b 100644 --- a/src/config/ConfigValue.hpp +++ b/src/config/ConfigValue.hpp @@ -11,7 +11,7 @@ template class CConfigValue { public: CConfigValue(const std::string& val) { - const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val.c_str()); + const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val); p_ = PVHYPRLANG->getDataStaticPtr(); diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 16bf297c..3f387d31 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -62,18 +62,22 @@ class IWindowTransformer; template class CWindowOverridableVar { public: - CWindowOverridableVar(T val) { + CWindowOverridableVar(T const& val) { value = val; } ~CWindowOverridableVar() = default; - CWindowOverridableVar& operator=(CWindowOverridableVar other) { - if (locked) + CWindowOverridableVar& operator=(CWindowOverridableVar const& other) { + // Self-assignment check + if (this == &other) return *this; - locked = other.locked; - value = other.value; + // Check if the current object is locked + if (!locked) { + locked = other.locked; + value = other.value; + } return *this; } @@ -85,36 +89,36 @@ class CWindowOverridableVar { return other; } - void forceSetIgnoreLocked(T val, bool lock = false) { + void forceSetIgnoreLocked(T const& val, bool lock = false) { value = val; locked = lock; } - T operator*(T& other) { + T operator*(T const& other) { return value * other; } - T operator+(T& other) { + T operator+(T const& other) { return value + other; } - bool operator==(T& other) { + bool operator==(T const& other) { return other == value; } - bool operator>=(T& other) { + bool operator>=(T const& other) { return value >= other; } - bool operator<=(T& other) { + bool operator<=(T const& other) { return value <= other; } - bool operator>(T& other) { + bool operator>(T const& other) { return value > other; } - bool operator<(T& other) { + bool operator<(T const& other) { return value < other; } diff --git a/src/helpers/WLListener.cpp b/src/helpers/WLListener.cpp index 978ff034..2ea5c0b6 100644 --- a/src/helpers/WLListener.cpp +++ b/src/helpers/WLListener.cpp @@ -18,7 +18,7 @@ void handleWrapped(wl_listener* listener, void* data) { g_pWatchdog->endWatching(); } -CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function callback, void* pOwner) { +CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function const& callback, void* pOwner) { initCallback(pSignal, callback, pOwner); } @@ -44,7 +44,7 @@ bool CHyprWLListener::isConnected() { return !wl_list_empty(&m_swWrapper.m_sListener.link); } -void CHyprWLListener::initCallback(wl_signal* pSignal, std::function callback, void* pOwner, std::string author) { +void CHyprWLListener::initCallback(wl_signal* pSignal, std::function const& callback, void* pOwner, std::string author) { if (isConnected()) { Debug::log(ERR, "Tried to connect a listener twice?!"); return; diff --git a/src/helpers/WLListener.hpp b/src/helpers/WLListener.hpp index d5d925b0..621458e6 100644 --- a/src/helpers/WLListener.hpp +++ b/src/helpers/WLListener.hpp @@ -6,7 +6,7 @@ class CHyprWLListener { public: - CHyprWLListener(wl_signal*, std::function, void* owner); + CHyprWLListener(wl_signal*, std::function const&, void* owner); CHyprWLListener(); ~CHyprWLListener(); @@ -15,7 +15,7 @@ class CHyprWLListener { CHyprWLListener& operator=(const CHyprWLListener&) = delete; CHyprWLListener& operator=(CHyprWLListener&&) = delete; - void initCallback(wl_signal*, std::function, void* owner, std::string author = ""); + void initCallback(wl_signal*, std::function const&, void* owner, std::string author = ""); void removeCallback(); diff --git a/src/protocols/types/DMABuffer.cpp b/src/protocols/types/DMABuffer.cpp index f26328e9..7c3a9886 100644 --- a/src/protocols/types/DMABuffer.cpp +++ b/src/protocols/types/DMABuffer.cpp @@ -3,7 +3,7 @@ #include "../../render/Renderer.hpp" #include "../../helpers/Format.hpp" -CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs attrs_) : attrs(attrs_) { +CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs const& attrs_) : attrs(attrs_) { g_pHyprRenderer->makeEGLCurrent(); listeners.resourceDestroy = events.destroy.registerListener([this](std::any d) { diff --git a/src/protocols/types/DMABuffer.hpp b/src/protocols/types/DMABuffer.hpp index dac89493..d07840b7 100644 --- a/src/protocols/types/DMABuffer.hpp +++ b/src/protocols/types/DMABuffer.hpp @@ -4,7 +4,7 @@ class CDMABuffer : public IWLBuffer { public: - CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs attrs_); + CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs const& attrs_); virtual ~CDMABuffer(); virtual eBufferCapability caps();