mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-31 21:38:06 -04:00
feat: carousel-like behaviour when swapping tags
This commit is contained in:
parent
4be9e80355
commit
78f7ed6825
4 changed files with 57 additions and 19 deletions
|
|
@ -1241,9 +1241,18 @@ int32_t tagtoleft(const Arg *arg) {
|
|||
return 0;
|
||||
|
||||
if (selmon->sel != NULL &&
|
||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
|
||||
selmon->tagset[selmon->seltags] > 1) {
|
||||
tag(&(Arg){.ui = selmon->tagset[selmon->seltags] >> 1, .i = arg->i});
|
||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1) {
|
||||
uint32_t target = selmon->tagset[selmon->seltags] >> 1;
|
||||
|
||||
if (target == 0) {
|
||||
if (!config.tag_carousel)
|
||||
return 0;
|
||||
target = (1 << (LENGTH(tags) - 1)) & TAGMASK;
|
||||
selmon->carousel_anim_dir = -1;
|
||||
}
|
||||
|
||||
tag(&(Arg){.ui = target & TAGMASK, .i = arg->i});
|
||||
selmon->carousel_anim_dir = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1253,9 +1262,18 @@ int32_t tagtoright(const Arg *arg) {
|
|||
return 0;
|
||||
|
||||
if (selmon->sel != NULL &&
|
||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
|
||||
selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
|
||||
tag(&(Arg){.ui = selmon->tagset[selmon->seltags] << 1, .i = arg->i});
|
||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1) {
|
||||
uint32_t target = selmon->tagset[selmon->seltags] << 1;
|
||||
|
||||
if (!(target & TAGMASK)) {
|
||||
if (!config.tag_carousel)
|
||||
return 0;
|
||||
target = 1;
|
||||
selmon->carousel_anim_dir = 1;
|
||||
}
|
||||
|
||||
tag(&(Arg){.ui = target & TAGMASK, .i = arg->i});
|
||||
selmon->carousel_anim_dir = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1495,22 +1513,24 @@ int32_t viewtoleft(const Arg *arg) {
|
|||
if (!selmon)
|
||||
return 0;
|
||||
|
||||
uint32_t target = selmon->tagset[selmon->seltags];
|
||||
|
||||
if (selmon->isoverview || selmon->pertag->curtag == 0) {
|
||||
if (selmon->isoverview || selmon->pertag->curtag == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t target = selmon->tagset[selmon->seltags];
|
||||
target >>= 1;
|
||||
|
||||
if (target == 0) {
|
||||
return 0;
|
||||
if (!config.tag_carousel)
|
||||
return 0;
|
||||
target = (1 << (LENGTH(tags) - 1)) & TAGMASK;
|
||||
selmon->carousel_anim_dir = -1;
|
||||
}
|
||||
|
||||
if (!selmon || (target) == selmon->tagset[selmon->seltags])
|
||||
if (target == selmon->tagset[selmon->seltags])
|
||||
return 0;
|
||||
|
||||
view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true);
|
||||
selmon->carousel_anim_dir = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1518,19 +1538,24 @@ int32_t viewtoright(const Arg *arg) {
|
|||
if (!selmon)
|
||||
return 0;
|
||||
|
||||
if (selmon->isoverview || selmon->pertag->curtag == 0) {
|
||||
if (selmon->isoverview || selmon->pertag->curtag == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t target = selmon->tagset[selmon->seltags];
|
||||
target <<= 1;
|
||||
|
||||
if (!selmon || (target) == selmon->tagset[selmon->seltags])
|
||||
return 0;
|
||||
if (!(target & TAGMASK)) {
|
||||
return 0;
|
||||
if (!config.tag_carousel)
|
||||
return 0;
|
||||
target = 1;
|
||||
selmon->carousel_anim_dir = 1;
|
||||
}
|
||||
|
||||
if (target == selmon->tagset[selmon->seltags])
|
||||
return 0;
|
||||
|
||||
view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true);
|
||||
selmon->carousel_anim_dir = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue