diff --git a/include/events/signal.hpp b/include/events/signal.hpp index cbc4b2f4..64ad28dd 100644 --- a/include/events/signal.hpp +++ b/include/events/signal.hpp @@ -41,38 +41,18 @@ namespace signals { class value_signal : public base_signal { public: using base_type = value_signal; - using value_type = ValueType; - template - explicit value_signal(void* data) : m_data(data), m_size(Size) {} + explicit value_signal(void* data) : m_ptr(data) {} + explicit value_signal(ValueType&& data) : m_ptr(&data) {} - template - explicit value_signal(ValueType data) : m_size(Size) { - m_data = new char[Size]; - m_alloced = true; - memcpy(m_data, static_cast(&data), Size); - } + virtual ~value_signal() {} - virtual ~value_signal() { - if (m_alloced) { - delete[] static_cast(m_data); - } - } - - void* data() const { - return m_data; - } - size_t size() const { - return m_size; - } inline ValueType cast() const { - return *static_cast(m_data); + return *static_cast(m_ptr); } private: - void* m_data; - size_t m_size; - bool m_alloced{false}; + void* m_ptr; }; } diff --git a/src/components/bar.cpp b/src/components/bar.cpp index a323e88e..e0ed44d3 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -514,7 +514,7 @@ void bar::handle(const evt::leave_notify&) { if (!m_opts.dimmed) { m_taskqueue->defer_unique("window-dim", 3s, [&](size_t) { m_opts.dimmed = true; - m_sig.emit(dim_window{m_opts.dimvalue}); + m_sig.emit(dim_window{double(m_opts.dimvalue)}); }); } } diff --git a/src/components/controller.cpp b/src/components/controller.cpp index dcf56e83..fa4034bb 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -222,7 +222,7 @@ bool controller::enqueue(string&& input_data) { } else if (chrono::system_clock::now() - m_swallow_input < m_lastinput) { m_log.trace("controller: Swallowing input event (throttled)"); } else { - m_inputdata = input_data; + m_inputdata = forward(input_data); return enqueue(make_input_evt()); } return false; diff --git a/src/components/parser.cpp b/src/components/parser.cpp index 04993cff..562140e8 100644 --- a/src/components/parser.cpp +++ b/src/components/parser.cpp @@ -184,7 +184,7 @@ size_t parser::text(string&& data) { } pkt.length = len; - m_sig.emit(write_text_string{static_cast(&pkt)}); + m_sig.emit(write_text_string{move(pkt)}); } if (pos > 0) { diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index d906a9d4..ceeccdd8 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -707,7 +707,7 @@ bool renderer::on(const write_text_unicode& evt) { } bool renderer::on(const write_text_string& evt) { - auto pkt = *static_cast(evt.data()); + auto pkt = evt.cast(); draw_textstring(pkt.data, pkt.length); return true; } diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp index 277d91b3..1bc7014e 100644 --- a/src/x11/tray_manager.cpp +++ b/src/x11/tray_manager.cpp @@ -1097,7 +1097,7 @@ void tray_manager::handle(const evt::map_notify& evt) { if (clientcount > m_opts.configured_slots) { reconfigure(); } - m_sig.emit(signals::ui_tray::mapped_clients{clientcount}); + m_sig.emit(signals::ui_tray::mapped_clients{move(clientcount)}); } }