mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-19 08:30:22 -07:00
Implements an intermediary HID class for mice, keyboards and touch devices, removing the old structs from WLClasses.hpp Yes, virtual ones are duplicated a bit, but will likely be de-duped once wlr_input_device is not used anymore.
30 lines
898 B
C++
30 lines
898 B
C++
#include "Signal.hpp"
|
|
#include <algorithm>
|
|
|
|
void CSignal::emit(std::any data) {
|
|
bool dirty = false;
|
|
|
|
for (auto& l : m_vListeners) {
|
|
if (const CHyprSignalListener L = l.lock())
|
|
L->emit(data);
|
|
else
|
|
dirty = true;
|
|
}
|
|
|
|
for (auto& l : m_vStaticListeners) {
|
|
l->emit(data);
|
|
}
|
|
|
|
if (dirty)
|
|
std::erase_if(m_vListeners, [](const auto& other) { return other.expired(); });
|
|
}
|
|
|
|
CHyprSignalListener CSignal::registerListener(std::function<void(std::any)> handler) {
|
|
CHyprSignalListener listener = std::make_shared<CSignalListener>(handler);
|
|
m_vListeners.emplace_back(std::weak_ptr<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));
|
|
} |