dwm: Add layout-reverse-scroll option

This option simply reverses the direction in which the scroll cycles through the
layouts.
This commit is contained in:
Mihir Lad 2020-07-21 18:45:26 -04:00
parent a22b2ffcc3
commit f3047ab1e5
3 changed files with 14 additions and 2 deletions

View File

@ -174,6 +174,7 @@ enable-tags-click = false
enable-layout-click = false enable-layout-click = false
enable-layout-scroll = false enable-layout-scroll = false
layout-scroll-wrap = false layout-scroll-wrap = false
layout-scroll-reverse = false
; If enable-layout-click = true, clicking the layout symbol will switch to this layout ; If enable-layout-click = true, clicking the layout symbol will switch to this layout
secondary-layout-symbol = [M] secondary-layout-symbol = [M]

View File

@ -258,6 +258,11 @@ namespace modules {
*/ */
bool m_layout_wrap{true}; bool m_layout_wrap{true};
/**
* If true, scrolling the layout will cycle layouts in the reverse direction
*/
bool m_layout_reverse{false};
/** /**
* If the layout symbol is clicked on, it will set the layout represented by * If the layout symbol is clicked on, it will set the layout represented by
* this symbol. The default is monocle mode [M]. * this symbol. The default is monocle mode [M].

View File

@ -58,6 +58,7 @@ namespace modules {
m_layout_click = m_conf.get(name(), "enable-layout-click", m_layout_click); m_layout_click = m_conf.get(name(), "enable-layout-click", m_layout_click);
m_layout_scroll = m_conf.get(name(), "enable-layout-scroll", m_layout_scroll); m_layout_scroll = m_conf.get(name(), "enable-layout-scroll", m_layout_scroll);
m_layout_wrap = m_conf.get(name(), "layout-scroll-wrap", m_layout_wrap); m_layout_wrap = m_conf.get(name(), "layout-scroll-wrap", m_layout_wrap);
m_layout_reverse = m_conf.get(name(), "layout-scroll-reverse", m_layout_reverse);
m_secondary_layout_symbol = m_conf.get(name(), "secondary-layout-symbol", m_secondary_layout_symbol); m_secondary_layout_symbol = m_conf.get(name(), "secondary-layout-symbol", m_secondary_layout_symbol);
try { try {
@ -164,8 +165,13 @@ 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) {
builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_prev))); builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_prev)));
builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_next))); builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_next)));
} else {
builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_next)));
builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_prev)));
}
} }
builder->node(m_layout_label); builder->node(m_layout_label);
if (m_layout_click) { if (m_layout_click) {