From 8c64a4bad710fb18e9b84812bd680a89d1e93661 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:17:45 +0200 Subject: core: move to hyprutils for utils (#6385) * core: move to hyprutils for utils Nix: add hyprutils dep * Meson: add hyprutils dep * flake.lock: update --------- Co-authored-by: Mihai Fufezan --- src/helpers/signal/Signal.cpp | 51 ------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/helpers/signal/Signal.cpp (limited to 'src/helpers/signal/Signal.cpp') diff --git a/src/helpers/signal/Signal.cpp b/src/helpers/signal/Signal.cpp deleted file mode 100644 index fd2d11c8..00000000 --- a/src/helpers/signal/Signal.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "Signal.hpp" -#include - -void CSignal::emit(std::any data) { - bool dirty = false; - - std::vector> listeners; - for (auto& l : m_vListeners) { - if (l.expired()) { - dirty = true; - continue; - } - - listeners.emplace_back(l.lock()); - } - - std::vector statics; - for (auto& l : m_vStaticListeners) { - statics.emplace_back(l.get()); - } - - for (auto& l : listeners) { - // if there is only one lock, it means the event is only held by the listeners - // vector and was removed during our iteration - if (l.strongRef() == 1) { - dirty = true; - continue; - } - l->emit(data); - } - - for (auto& l : statics) { - l->emit(data); - } - - // release SPs - listeners.clear(); - - if (dirty) - std::erase_if(m_vListeners, [](const auto& other) { return other.expired(); }); -} - -CHyprSignalListener CSignal::registerListener(std::function handler) { - CHyprSignalListener listener = makeShared(handler); - m_vListeners.emplace_back(WP(listener)); - return listener; -} - -void CSignal::registerStaticListener(std::function handler, void* owner) { - m_vStaticListeners.emplace_back(std::make_unique(handler, owner)); -} \ No newline at end of file -- cgit v1.2.3