From 7562ca735641691e8aa04c1330eab63ca1ff4988 Mon Sep 17 00:00:00 2001 From: lilly-lizard Date: Tue, 7 Apr 2026 06:49:51 +1200 Subject: [PATCH] silent varients of tag assignment commands --- src/config/parse_config.h | 13 ++++++++++ src/dispatch/bind_declare.h | 3 +++ src/dispatch/bind_define.h | 50 ++++++++++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 830d22ba..a07c2034 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -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); diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index 22ef6123..fc0fa2de 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -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); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index bd065141..d7725425 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -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;