mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-03 06:46:38 -04:00
added tagtoside_general to reduce code duplication
This commit is contained in:
parent
e3f30ca065
commit
5f88f7f803
1 changed files with 18 additions and 31 deletions
|
|
@ -1193,7 +1193,7 @@ int32_t tagsilent(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tagtoleft_general(const Arg *arg, bool silent) {
|
int32_t tagtoside_general(const Arg *arg, bool silent, bool left) {
|
||||||
if (!selmon)
|
if (!selmon)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -1201,11 +1201,20 @@ int32_t tagtoleft_general(const Arg *arg, bool silent) {
|
||||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1) {
|
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1) {
|
||||||
|
|
||||||
uint32_t target = selmon->tagset[selmon->seltags];
|
uint32_t target = selmon->tagset[selmon->seltags];
|
||||||
if (target & 1) {
|
|
||||||
// 1 wraps around to 9
|
if (left) {
|
||||||
target |= 1 << LENGTH(tags);
|
if (target & 1) {
|
||||||
|
// 1 wraps around to 9
|
||||||
|
target |= 1 << LENGTH(tags);
|
||||||
|
}
|
||||||
|
target >>= 1;
|
||||||
|
} else {
|
||||||
|
target <<= 1;
|
||||||
|
if (target & 1 << LENGTH(tags)) {
|
||||||
|
// 9 wraps around to 1
|
||||||
|
target |= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
target >>= 1;
|
|
||||||
|
|
||||||
if (silent)
|
if (silent)
|
||||||
tagsilent(&(Arg){.ui = target, .i = arg->i});
|
tagsilent(&(Arg){.ui = target, .i = arg->i});
|
||||||
|
|
@ -1216,41 +1225,19 @@ int32_t tagtoleft_general(const Arg *arg, bool silent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tagtoleft(const Arg *arg) {
|
int32_t tagtoleft(const Arg *arg) {
|
||||||
return tagtoleft_general(arg, false);
|
return tagtoside_general(arg, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tagtoleftsilent(const Arg *arg) {
|
int32_t tagtoleftsilent(const Arg *arg) {
|
||||||
return tagtoleft_general(arg, true);
|
return tagtoside_general(arg, true, true);
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tagtoright_general(const Arg *arg, bool silent) {
|
|
||||||
if (!selmon)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (selmon->sel != NULL &&
|
|
||||||
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1) {
|
|
||||||
|
|
||||||
uint32_t target = selmon->tagset[selmon->seltags];
|
|
||||||
target <<= 1;
|
|
||||||
if (target & 1 << LENGTH(tags)) {
|
|
||||||
// 9 wraps around to 1
|
|
||||||
target |= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (silent)
|
|
||||||
tagsilent(&(Arg){.ui = target, .i = arg->i});
|
|
||||||
else
|
|
||||||
tag(&(Arg){.ui = target, .i = arg->i});
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tagtoright(const Arg *arg) {
|
int32_t tagtoright(const Arg *arg) {
|
||||||
return tagtoright_general(arg, false);
|
return tagtoside_general(arg, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tagtorightsilent(const Arg *arg) {
|
int32_t tagtorightsilent(const Arg *arg) {
|
||||||
return tagtoright_general(arg, true);
|
return tagtoside_general(arg, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t toggle_named_scratchpad(const Arg *arg) {
|
int32_t toggle_named_scratchpad(const Arg *arg) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue