diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-06-11 17:17:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-11 17:17:45 +0200 |
| commit | 8c64a4bad710fb18e9b84812bd680a89d1e93661 (patch) | |
| tree | 2439b8408abd8e14f6af35ef9cfbeb7c51429f99 /src/helpers/signal/Signal.cpp | |
| parent | 1f46296ea05f9a8e6020ab694b531c91a1abdfa6 (diff) | |
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 <mihai@fufexan.net>
Diffstat (limited to 'src/helpers/signal/Signal.cpp')
| -rw-r--r-- | src/helpers/signal/Signal.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
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 <algorithm> - -void CSignal::emit(std::any data) { - bool dirty = false; - - std::vector<SP<CSignalListener>> listeners; - for (auto& l : m_vListeners) { - if (l.expired()) { - dirty = true; - continue; - } - - listeners.emplace_back(l.lock()); - } - - std::vector<CStaticSignalListener*> 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<void(std::any)> handler) { - CHyprSignalListener listener = makeShared<CSignalListener>(handler); - m_vListeners.emplace_back(WP<CSignalListener>(listener)); - return listener; -} - -void CSignal::registerStaticListener(std::function<void(void*, std::any)> handler, void* owner) { - m_vStaticListeners.emplace_back(std::make_unique<CStaticSignalListener>(handler, owner)); -}
\ No newline at end of file |
