wip(refactor): Improve signal and event handling

This commit is contained in:
Michael Carlberg
2016-12-05 20:41:00 +01:00
parent d45fd76dcd
commit 08be86fbe1
73 changed files with 2228 additions and 2251 deletions

View File

@ -21,7 +21,7 @@ namespace modules {
*/
xbacklight_module::xbacklight_module(const bar_settings& bar, const logger& logger, const config& config, string name)
: static_module<xbacklight_module>(bar, logger, config, name)
, m_connection(configure_connection().create<connection&>()) {}
, m_connection(make_connection()) {}
/**
* Bootstrap the module by grabbing all required components
@ -60,9 +60,6 @@ namespace modules {
throw module_error("Failed to create event proxy");
}
// Get the throttle time
m_randrnotify.offset = xutils::event_timer_ms(m_conf, xcb_randr_notify_event_t{});
// Connect with the event registry and make sure we get
// notified when a RandR output property gets modified
m_connection.attach_sink(this, SINK_PRIORITY_MODULE);
@ -106,8 +103,6 @@ namespace modules {
return;
} else if (evt->u.op.atom != m_output->backlight.atom) {
return;
} else if (m_randrnotify.deny(evt->u.op.timestamp)) {
return m_log.trace_x("%s: Ignoring randr notify (throttled)...", name());
} else {
update();
}
@ -142,8 +137,8 @@ namespace modules {
// with the cmd handlers
string output{module::get_output()};
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLLUP, m_scroll && m_percentage < 100);
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLLDOWN, m_scroll && m_percentage > 0);
m_builder->cmd(mousebtn::SCROLL_UP, string{EVENT_SCROLLUP}, m_scroll && m_percentage < 100);
m_builder->cmd(mousebtn::SCROLL_DOWN, string{EVENT_SCROLLDOWN}, m_scroll && m_percentage > 0);
m_builder->append(output);