dwm: Only initialize and use tags if label is used
Check the formatter for the tags label, and if it doesn't exist, there's no need to initialize the tags array or listen to tag change events. Also, check to see if tags are being used before trying to update them from the on_monitor_focus_change function.
This commit is contained in:
parent
b6c2dc0dee
commit
339d059441
@ -70,13 +70,19 @@ namespace modules {
|
|||||||
update_monitor_ref();
|
update_monitor_ref();
|
||||||
m_focused_client_id = m_bar_mon->clients.selected;
|
m_focused_client_id = m_bar_mon->clients.selected;
|
||||||
|
|
||||||
// Initialize tags array
|
if (m_formatter->has(TAG_LABEL_TAGS)) {
|
||||||
auto tags = m_ipc->get_tags();
|
// Initialize tags array
|
||||||
for (dwmipc::Tag& t : *tags) {
|
auto tags = m_ipc->get_tags();
|
||||||
auto state = get_state(t.bit_mask);
|
for (dwmipc::Tag& t : *tags) {
|
||||||
auto label = m_state_labels.at(state)->clone();
|
auto state = get_state(t.bit_mask);
|
||||||
label->replace_token("%name%", t.tag_name);
|
auto label = m_state_labels.at(state)->clone();
|
||||||
m_tags.emplace_back(t.tag_name, t.bit_mask, state, move(label));
|
label->replace_token("%name%", t.tag_name);
|
||||||
|
m_tags.emplace_back(t.tag_name, t.bit_mask, state, move(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This event is for keeping track of the tag states
|
||||||
|
m_ipc->on_tag_change = [this](const dwmipc::TagChangeEvent& ev) { this->on_tag_change(ev); };
|
||||||
|
m_ipc->subscribe(dwmipc::Event::TAG_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_floating_label) {
|
if (m_floating_label) {
|
||||||
@ -131,10 +137,6 @@ namespace modules {
|
|||||||
this->on_monitor_focus_change(ev);
|
this->on_monitor_focus_change(ev);
|
||||||
};
|
};
|
||||||
m_ipc->subscribe(dwmipc::Event::MONITOR_FOCUS_CHANGE);
|
m_ipc->subscribe(dwmipc::Event::MONITOR_FOCUS_CHANGE);
|
||||||
|
|
||||||
// This event is for keeping track of the tag states
|
|
||||||
m_ipc->on_tag_change = [this](const dwmipc::TagChangeEvent& ev) { this->on_tag_change(ev); };
|
|
||||||
m_ipc->subscribe(dwmipc::Event::TAG_CHANGE);
|
|
||||||
} catch (const dwmipc::IPCError& err) {
|
} catch (const dwmipc::IPCError& err) {
|
||||||
throw module_error(err.what());
|
throw module_error(err.what());
|
||||||
}
|
}
|
||||||
@ -430,7 +432,9 @@ namespace modules {
|
|||||||
|
|
||||||
void dwm_module::on_monitor_focus_change(const dwmipc::MonitorFocusChangeEvent& ev) {
|
void dwm_module::on_monitor_focus_change(const dwmipc::MonitorFocusChangeEvent& ev) {
|
||||||
m_active_mon = &m_monitors->at(ev.new_mon_num);
|
m_active_mon = &m_monitors->at(ev.new_mon_num);
|
||||||
update_tag_labels();
|
if (m_formatter->has(TAG_LABEL_TAGS)) {
|
||||||
|
update_tag_labels();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwm_module::on_tag_change(const dwmipc::TagChangeEvent& ev) {
|
void dwm_module::on_tag_change(const dwmipc::TagChangeEvent& ev) {
|
||||||
|
Loading…
Reference in New Issue
Block a user