From b422d1d1a4f95fa4ec37d01f6a49949c37216f17 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 23 Dec 2016 20:43:52 +0100 Subject: [PATCH] refactor(modules): Input handling --- include/components/controller.hpp | 8 ++--- include/events/signal.hpp | 5 ++- include/events/signal_fwd.hpp | 1 - include/modules/bspwm.hpp | 2 +- include/modules/date.hpp | 2 +- include/modules/i3.hpp | 2 +- include/modules/menu.hpp | 2 +- include/modules/meta/input_handler.hpp | 6 ++-- include/modules/mpd.hpp | 2 +- include/modules/volume.hpp | 2 +- include/modules/xbacklight.hpp | 2 +- include/modules/xkeyboard.hpp | 2 +- include/modules/xworkspaces.hpp | 2 +- src/components/controller.cpp | 45 ++++++++++---------------- src/modules/bspwm.cpp | 4 +-- src/modules/date.cpp | 5 +-- src/modules/i3.cpp | 11 +++---- src/modules/menu.cpp | 4 +-- src/modules/mpd.cpp | 4 +-- src/modules/volume.cpp | 4 +-- src/modules/xbacklight.cpp | 4 +-- src/modules/xkeyboard.cpp | 4 +-- src/modules/xworkspaces.cpp | 25 ++++++-------- 23 files changed, 55 insertions(+), 93 deletions(-) diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 94c67888..d3e63cd0 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -26,6 +26,7 @@ class signal_emitter; namespace modules { struct module_interface; + class input_handler; } using module_t = unique_ptr; @@ -42,7 +43,7 @@ namespace sig_ui = signals::ui; namespace sig_ipc = signals::ipc; class controller : public signal_receiver { public: using make_type = unique_ptr; @@ -55,7 +56,7 @@ class controller : public signal_receiver m_inputhandlers; + vector m_inputhandlers; /** * @brief Maximum number of subsequent events to swallow diff --git a/include/events/signal.hpp b/include/events/signal.hpp index 3f3e758f..abe25af0 100644 --- a/include/events/signal.hpp +++ b/include/events/signal.hpp @@ -94,9 +94,8 @@ namespace signals { namespace eventqueue { DEFINE_VALUE_SIGNAL(1, process_quit, event); DEFINE_VALUE_SIGNAL(2, process_update, event); - DEFINE_VALUE_SIGNAL(3, process_input, string); - DEFINE_SIGNAL(4, process_check); - DEFINE_SIGNAL(5, process_broadcast); + DEFINE_SIGNAL(3, process_check); + DEFINE_SIGNAL(4, process_broadcast); } namespace ipc { diff --git a/include/events/signal_fwd.hpp b/include/events/signal_fwd.hpp index c438501b..98f71b63 100644 --- a/include/events/signal_fwd.hpp +++ b/include/events/signal_fwd.hpp @@ -8,7 +8,6 @@ namespace signals { namespace eventqueue { struct process_quit; struct process_update; - struct process_input; struct process_check; struct process_broadcast; } diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index b0177b9b..80710524 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -47,7 +47,7 @@ namespace modules { bool build(builder* builder, const string& tag) const; protected: - bool on(const input_event_t& evt); + bool input(string&& cmd); private: static constexpr auto DEFAULT_ICON = "ws-icon-default"; diff --git a/include/modules/date.hpp b/include/modules/date.hpp index 1dcf62a0..f20c076f 100644 --- a/include/modules/date.hpp +++ b/include/modules/date.hpp @@ -14,7 +14,7 @@ namespace modules { bool build(builder* builder, const string& tag) const; protected: - bool on(const input_event_t& evt); + bool input(string&& cmd); private: static constexpr auto TAG_LABEL = "