From ce96b774d7465e48866810aecf5f6f95f5ad2da0 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 29 Oct 2025 13:06:05 +0800 Subject: [PATCH] feat: add dispatch viewcrossmon and tagcrossmon --- src/config/parse_config.h | 10 +++++++++- src/dispatch/bind_declare.h | 2 ++ src/dispatch/bind_define.h | 25 +++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 1556895..ba7dcb4 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -938,7 +938,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, } else if (strcmp(func_name, "tagmon") == 0) { func = tagmon; (*arg).i = parse_direction(arg_value); - (*arg).ui = atoi(arg_value2); + (*arg).i2 = atoi(arg_value2); if ((*arg).i == UNDIR) { (*arg).v = strdup(arg_value); }; @@ -987,6 +987,14 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, func = bind_to_view; (*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).i = atoi(arg_value2); + } else if (strcmp(func_name, "viewcrossmon") == 0) { + func = viewcrossmon; + (*arg).ui = 1 << (atoi(arg_value) - 1); + (*arg).v = strdup(arg_value2); + } else if (strcmp(func_name, "tagcrossmon") == 0) { + func = tagcrossmon; + (*arg).ui = 1 << (atoi(arg_value) - 1); + (*arg).v = strdup(arg_value2); } else if (strcmp(func_name, "toggletag") == 0) { func = toggletag; (*arg).ui = 1 << (atoi(arg_value) - 1); diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index b8470fc..c57a132 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -10,10 +10,12 @@ int zoom(const Arg *arg); int tagsilent(const Arg *arg); int tagtoleft(const Arg *arg); int tagtoright(const Arg *arg); +int tagcrossmon(const Arg *arg); int viewtoleft(const Arg *arg); int viewtoright(const Arg *arg); int viewtoleft_have_client(const Arg *arg); int viewtoright_have_client(const Arg *arg); +int viewcrossmon(const Arg *arg); int togglefloating(const Arg *arg); int togglefullscreen(const Arg *arg); int togglemaximizescreen(const Arg *arg); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 1b0fe47..e487473 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1054,11 +1054,17 @@ int tagmon(const Arg *arg) { return 0; } - if (!m || !m->wlr_output->enabled || m == c->mon) + if (!m || !m->wlr_output->enabled) return 0; - unsigned int newtags = arg->ui ? c->tags : 0; + unsigned int newtags = arg->ui ? arg->ui : arg->i2 ? c->tags : 0; unsigned int target; + + if (c->mon == m) { + view(&(Arg){.ui = newtags}, true); + return 0; + } + if (c == selmon->sel) { selmon->sel = NULL; } @@ -1075,6 +1081,7 @@ int tagmon(const Arg *arg) { selmon = c->mon; c->float_geom = setclient_coordinate_center(c, c->float_geom, 0, 0); + // 重新计算居中的坐标 // 重新计算居中的坐标 if (c->isfloating) { c->geom = c->float_geom; @@ -1418,6 +1425,20 @@ int viewtoright_have_client(const Arg *arg) { return 0; } +int viewcrossmon(const Arg *arg) { + focusmon(arg); + view_in_mon(arg, true, selmon, true); + return 0; +} + +int tagcrossmon(const Arg *arg) { + if (!selmon->sel) + return 0; + + tagmon(&(Arg){.ui = arg->ui, .i = UNDIR, .v = arg->v}); + return 0; +} + int comboview(const Arg *arg) { unsigned int newtags = arg->ui & TAGMASK;