dwm: Simplify layout scroll command build

This way reduces the code a couple lines, takes less indentation, while still
being clear in functionality.
This commit is contained in:
Mihir Lad 2020-07-21 19:05:09 -04:00
parent 33c8fb2ac7
commit b3bf969a0a

View File

@ -165,13 +165,11 @@ namespace modules {
if (m_layout_scroll) { if (m_layout_scroll) {
auto addr_next = next_layout(*m_current_layout, m_layout_wrap)->address; auto addr_next = next_layout(*m_current_layout, m_layout_wrap)->address;
auto addr_prev = prev_layout(*m_current_layout, m_layout_wrap)->address; auto addr_prev = prev_layout(*m_current_layout, m_layout_wrap)->address;
if (m_layout_reverse) { // Set address based on scroll direction
builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, to_string(addr_prev))); auto scroll_down_addr = to_string(m_layout_reverse ? addr_prev : addr_next);
builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, to_string(addr_next))); auto scroll_up_addr = to_string(m_layout_reverse ? addr_next : addr_prev);
} else { builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, scroll_down_addr));
builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, to_string(addr_next))); builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, scroll_up_addr));
builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, to_string(addr_prev)));
}
} }
builder->node(m_layout_label); builder->node(m_layout_label);
if (m_layout_click) { if (m_layout_click) {