silent varients of tag assignment commands

This commit is contained in:
lilly-lizard 2026-04-07 06:49:51 +12:00
parent 722f9f6876
commit 7562ca7356
3 changed files with 57 additions and 9 deletions

View file

@ -957,9 +957,15 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
} else if (strcmp(func_name, "tagtoleft") == 0) {
func = tagtoleft;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "tagtoleftsilent") == 0) {
func = tagtoleftsilent;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "tagtoright") == 0) {
func = tagtoright;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "tagtorightsilent") == 0) {
func = tagtorightsilent;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "killclient") == 0) {
func = killclient;
} else if (strcmp(func_name, "centerwin") == 0) {
@ -1052,6 +1058,13 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
if ((*arg).i == UNDIR) {
(*arg).v = strdup(arg_value);
};
} else if (strcmp(func_name, "tagmonsilent") == 0) {
func = tagmonsilent;
(*arg).i = parse_direction(arg_value);
(*arg).i2 = atoi(arg_value2);
if ((*arg).i == UNDIR) {
(*arg).v = strdup(arg_value);
};
} else if (strcmp(func_name, "incgaps") == 0) {
func = incgaps;
(*arg).i = atoi(arg_value);

View file

@ -8,7 +8,9 @@ int32_t switch_proportion_preset(const Arg *arg);
int32_t zoom(const Arg *arg);
int32_t tagsilent(const Arg *arg);
int32_t tagtoleft(const Arg *arg);
int32_t tagtoleftsilent(const Arg *arg);
int32_t tagtoright(const Arg *arg);
int32_t tagtorightsilent(const Arg *arg);
int32_t tagcrossmon(const Arg *arg);
int32_t viewtoleft(const Arg *arg);
int32_t viewtoright(const Arg *arg);
@ -20,6 +22,7 @@ int32_t togglefullscreen(const Arg *arg);
int32_t togglemaximizescreen(const Arg *arg);
int32_t togglegaps(const Arg *arg);
int32_t tagmon(const Arg *arg);
int32_t tagmonsilent(const Arg *arg);
int32_t spawn(const Arg *arg);
int32_t spawn_shell(const Arg *arg);
int32_t spawn_on_empty(const Arg *arg);

View file

@ -1044,6 +1044,14 @@ int32_t tag(const Arg *arg) {
}
int32_t tagmon(const Arg *arg) {
tagmon_general(arg, false);
}
int32_t tagmonsilent(const Arg *arg) {
tagmon_general(arg, true);
}
int32_t tagmon_general(const Arg *arg, bool silent) {
Monitor *m = NULL, *cm = NULL;
Client *c = focustop(selmon);
@ -1073,7 +1081,9 @@ int32_t tagmon(const Arg *arg) {
uint32_t target;
if (c->mon == m) {
view(&(Arg){.ui = newtags}, true);
if (!silent) {
view(&(Arg){.ui = newtags}, true);
}
return 0;
}
@ -1081,7 +1091,7 @@ int32_t tagmon(const Arg *arg) {
selmon->sel = NULL;
}
setmon(c, m, newtags, true);
setmon(c, m, newtags, !silent); // todo silent, last arg = false
client_update_oldmonname_record(c, m);
reset_foreign_tolevel(c);
@ -1097,18 +1107,22 @@ int32_t tagmon(const Arg *arg) {
// 重新计算居中的坐标
if (c->isfloating) {
c->geom = c->float_geom;
target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true);
focusclient(c, 1);
if (!silent) {
target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true);
focusclient(c, 1);
}
resize(c, c->geom, 1);
} else {
selmon = c->mon;
target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true);
focusclient(c, 1);
if (!silent) {
target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true);
focusclient(c, 1);
}
arrange(selmon, false, false);
}
if (warpcursor) {
if (warpcursor && !silent) {
warp_cursor_to_selmon(c->mon);
}
return 0;
@ -1144,6 +1158,15 @@ int32_t tagtoleft(const Arg *arg) {
return 0;
}
int32_t tagtoleftsilent(const Arg *arg) {
if (selmon->sel != NULL &&
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] > 1) {
tagsilent(&(Arg){.ui = selmon->tagset[selmon->seltags] >> 1, .i = arg->i});
}
return 0;
}
int32_t tagtoright(const Arg *arg) {
if (selmon->sel != NULL &&
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
@ -1153,6 +1176,15 @@ int32_t tagtoright(const Arg *arg) {
return 0;
}
int32_t tagtorightsilent(const Arg *arg) {
if (selmon->sel != NULL &&
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
tagsilent(&(Arg){.ui = selmon->tagset[selmon->seltags] << 1, .i = arg->i});
}
return 0;
}
int32_t toggle_named_scratchpad(const Arg *arg) {
Client *target_client = NULL;
char *arg_id = arg->v;