From b3bf969a0ab3c56851f7090d35b4553bf12a5c30 Mon Sep 17 00:00:00 2001 From: Mihir Lad Date: Tue, 21 Jul 2020 19:05:09 -0400 Subject: [PATCH] dwm: Simplify layout scroll command build This way reduces the code a couple lines, takes less indentation, while still being clear in functionality. --- src/modules/dwm.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 94b8988d..c9e49c51 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -165,13 +165,11 @@ namespace modules { if (m_layout_scroll) { auto addr_next = next_layout(*m_current_layout, m_layout_wrap)->address; auto addr_prev = prev_layout(*m_current_layout, m_layout_wrap)->address; - if (m_layout_reverse) { - builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, to_string(addr_prev))); - builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, to_string(addr_next))); - } else { - builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, to_string(addr_next))); - builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, to_string(addr_prev))); - } + // Set address based on scroll direction + auto scroll_down_addr = to_string(m_layout_reverse ? addr_prev : addr_next); + auto scroll_up_addr = to_string(m_layout_reverse ? addr_next : addr_prev); + builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(CMD_LAYOUT_SET, scroll_down_addr)); + builder->cmd(mousebtn::SCROLL_UP, build_cmd(CMD_LAYOUT_SET, scroll_up_addr)); } builder->node(m_layout_label); if (m_layout_click) {