fix(xkeyboard): Wrap click handler around contents

This commit is contained in:
Michael Carlberg 2016-12-23 22:39:59 +01:00
parent 068d586757
commit bb0d6f580d
2 changed files with 19 additions and 3 deletions

View File

@ -25,6 +25,7 @@ namespace modules {
public: public:
explicit xkeyboard_module(const bar_settings& bar, string name_); explicit xkeyboard_module(const bar_settings& bar, string name_);
string get_output();
void update(); void update();
bool build(builder* builder, const string& tag) const; bool build(builder* builder, const string& tag) const;

View File

@ -76,15 +76,30 @@ namespace modules {
broadcast(); broadcast();
} }
/**
* Build module output and wrap it in a click handler use
* to cycle between configured layout groups
*/
string xkeyboard_module::get_output() {
string output{module::get_output()};
if (m_keyboard && m_keyboard->size() > 1) {
m_builder->cmd(mousebtn::LEFT, EVENT_SWITCH);
m_builder->append(output);
m_builder->cmd_close();
} else {
m_builder->append(output);
}
return m_builder->flush();
}
/** /**
* Map format tags to content * Map format tags to content
*/ */
bool xkeyboard_module::build(builder* builder, const string& tag) const { bool xkeyboard_module::build(builder* builder, const string& tag) const {
if (tag == TAG_LABEL_LAYOUT) { if (tag == TAG_LABEL_LAYOUT) {
bool precond{m_keyboard && m_keyboard->size() > 1};
builder->cmd(mousebtn::LEFT, EVENT_SWITCH, precond);
builder->node(m_layout); builder->node(m_layout);
builder->cmd_close(precond);
} else if (tag == TAG_LABEL_INDICATOR) { } else if (tag == TAG_LABEL_INDICATOR) {
size_t n{0}; size_t n{0};
for (auto&& indicator : m_indicators) { for (auto&& indicator : m_indicators) {