feat: add dispatch viewcrossmon and tagcrossmon

This commit is contained in:
DreamMaoMao
2025-10-29 13:06:05 +08:00
parent cbcbda25cd
commit 9b5ea50095
3 changed files with 34 additions and 3 deletions

View File

@@ -955,7 +955,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);
};
@@ -1004,6 +1004,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);

View File

@@ -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);

View File

@@ -1051,11 +1051,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;
}
@@ -1072,6 +1078,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;
@@ -1415,6 +1422,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;