feat(volume): Optional event handling #84
This commit is contained in:
parent
68beb8d744
commit
02833b7871
@ -154,6 +154,8 @@ namespace modules {
|
|||||||
vector<thread> m_threads;
|
vector<thread> m_threads;
|
||||||
thread m_mainthread;
|
thread m_mainthread;
|
||||||
|
|
||||||
|
bool m_handle_events{true};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
atomic<bool> m_enabled{true};
|
atomic<bool> m_enabled{true};
|
||||||
atomic<bool> m_changed{true};
|
atomic<bool> m_changed{true};
|
||||||
|
@ -17,7 +17,8 @@ namespace modules {
|
|||||||
, m_conf(config::make())
|
, m_conf(config::make())
|
||||||
, m_name("module/" + name)
|
, m_name("module/" + name)
|
||||||
, m_builder(make_unique<builder>(bar))
|
, m_builder(make_unique<builder>(bar))
|
||||||
, m_formatter(make_unique<module_formatter>(m_conf, m_name)) {}
|
, m_formatter(make_unique<module_formatter>(m_conf, m_name))
|
||||||
|
, m_handle_events(m_conf.get(m_name, "handle-events", true)) {}
|
||||||
|
|
||||||
template <typename Impl>
|
template <typename Impl>
|
||||||
module<Impl>::~module() noexcept {
|
module<Impl>::~module() noexcept {
|
||||||
|
@ -189,9 +189,11 @@ namespace modules {
|
|||||||
// with the cmd handlers
|
// with the cmd handlers
|
||||||
string output{module::get_output()};
|
string output{module::get_output()};
|
||||||
|
|
||||||
|
if (m_handle_events) {
|
||||||
m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE);
|
m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE);
|
||||||
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP);
|
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP);
|
||||||
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN);
|
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
m_builder->append(output);
|
m_builder->append(output);
|
||||||
|
|
||||||
@ -216,11 +218,11 @@ namespace modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool volume_module::input(string&& cmd) {
|
bool volume_module::input(string&& cmd) {
|
||||||
if (cmd.compare(0, 3, EVENT_PREFIX) != 0) {
|
if (!m_handle_events) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (cmd.compare(0, 3, EVENT_PREFIX) != 0) {
|
||||||
|
return false;
|
||||||
if (!m_mixer[mixer::MASTER]) {
|
} else if (!m_mixer[mixer::MASTER]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user