diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index ed91bb40..dfc64fb9 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1566,16 +1566,13 @@ int32_t viewtoleft_have_client(const Arg *arg) { if (!selmon) return 0; + if (selmon->isoverview) + return 0; + uint32_t n; uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]); bool found = false; - - if (selmon->isoverview) { - return 0; - } - - if (current <= 1) - return 0; + bool wrapped = false; for (n = current - 1; n >= 1; n--) { if (get_tag_status(n, selmon)) { @@ -1584,8 +1581,22 @@ int32_t viewtoleft_have_client(const Arg *arg) { } } - if (found) + if (!found && config.tag_carousel) { + for (n = LENGTH(tags); n > current; n--) { + if (get_tag_status(n, selmon)) { + found = true; + wrapped = true; + break; + } + } + } + + if (found) { + if (wrapped) + selmon->carousel_anim_dir = -1; view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK, .i = arg->i}, true); + selmon->carousel_anim_dir = 0; + } return 0; } @@ -1593,16 +1604,13 @@ int32_t viewtoright_have_client(const Arg *arg) { if (!selmon) return 0; + if (selmon->isoverview) + return 0; + uint32_t n; uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]); bool found = false; - - if (selmon->isoverview) { - return 0; - } - - if (current >= LENGTH(tags)) - return 0; + bool wrapped = false; for (n = current + 1; n <= LENGTH(tags); n++) { if (get_tag_status(n, selmon)) { @@ -1611,8 +1619,22 @@ int32_t viewtoright_have_client(const Arg *arg) { } } - if (found) + if (!found && config.tag_carousel) { + for (n = 1; n < current; n++) { + if (get_tag_status(n, selmon)) { + found = true; + wrapped = true; + break; + } + } + } + + if (found) { + if (wrapped) + selmon->carousel_anim_dir = 1; view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK, .i = arg->i}, true); + selmon->carousel_anim_dir = 0; + } return 0; }