From 254a23344a6b57019ca27aa775a3ccea9d0d23b6 Mon Sep 17 00:00:00 2001 From: brendo Date: Sun, 9 Aug 2020 07:25:25 +0800 Subject: [PATCH] proper wrap in prev_scrollable_tag --- src/modules/dwm.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 1b74f78f..cb55c6af 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -413,7 +413,13 @@ namespace modules { [this](const tag_t& tag) { return m_bar_mon->tag_state.selected & tag.bit_mask; }); if (current_tag_it != m_tags.end()) { auto prev = current_tag_it == m_tags.begin() ? current_tag_it : current_tag_it - 1; - if (m_tags_scroll_wrap && current_tag_it == m_tags.begin()) { + if (m_tags_scroll_wrap && + // if tag is the first tag + (current_tag_it == m_tags.begin() || + // or tag is the first non empty tag + (ignore_empty && &(*std::find_if(m_tags.begin(), m_tags.end(), [](const tag_t& tag) { + return tag.state != state_t::EMPTY; + })) == &(*current_tag_it)))) { // wrap the tag prev = m_tags.end() - 1; }