feat: tag action sync all monitor

This commit is contained in:
DreamMaoMao 2025-09-19 17:41:23 +08:00
parent 1dc2b51250
commit 47d24d6e8a
5 changed files with 76 additions and 54 deletions

View file

@ -183,35 +183,35 @@ bind=ALT,x,switch_proportion_preset,
bind=SUPER,n,switch_layout bind=SUPER,n,switch_layout
# tag switch # tag switch
bind=SUPER,Left,viewtoleft, bind=SUPER,Left,viewtoleft,0
bind=CTRL,Left,viewtoleft_have_client, bind=CTRL,Left,viewtoleft_have_client,0
bind=SUPER,Right,viewtoright, bind=SUPER,Right,viewtoright,0
bind=CTRL,Right,viewtoright_have_client, bind=CTRL,Right,viewtoright_have_client,0
bind=CTRL+SUPER,Left,tagtoleft, bind=CTRL+SUPER,Left,tagtoleft,0
bind=CTRL+SUPER,Right,tagtoright, bind=CTRL+SUPER,Right,tagtoright,0
bind=Ctrl,1,view,1 bind=Ctrl,1,view,1,0
bind=Ctrl,2,view,2 bind=Ctrl,2,view,2,0
bind=Ctrl,3,view,3 bind=Ctrl,3,view,3,0
bind=Ctrl,4,view,4 bind=Ctrl,4,view,4,0
bind=Ctrl,5,view,5 bind=Ctrl,5,view,5,0
bind=Ctrl,6,view,6 bind=Ctrl,6,view,6,0
bind=Ctrl,7,view,7 bind=Ctrl,7,view,7,0
bind=Ctrl,8,view,8 bind=Ctrl,8,view,8,0
bind=Ctrl,9,view,9 bind=Ctrl,9,view,9,0
# tag: move client to the tag and focus it # tag: move client to the tag and focus it
# tagsilent: move client to the tag and not focus it # tagsilent: move client to the tag and not focus it
# bind=Alt,1,tagsilent,1 # bind=Alt,1,tagsilent,1
bind=Alt,1,tag,1 bind=Alt,1,tag,1,0
bind=Alt,2,tag,2 bind=Alt,2,tag,2,0
bind=Alt,3,tag,3 bind=Alt,3,tag,3,0
bind=Alt,4,tag,4 bind=Alt,4,tag,4,0
bind=Alt,5,tag,5 bind=Alt,5,tag,5,0
bind=Alt,6,tag,6 bind=Alt,6,tag,6,0
bind=Alt,7,tag,7 bind=Alt,7,tag,7,0
bind=Alt,8,tag,8 bind=Alt,8,tag,8,0
bind=Alt,9,tag,9 bind=Alt,9,tag,9,0
# monitor switch # monitor switch
bind=alt+shift,Left,focusmon,left bind=alt+shift,Left,focusmon,left

View file

@ -726,15 +726,19 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
func = switch_proportion_preset; func = switch_proportion_preset;
} else if (strcmp(func_name, "viewtoleft") == 0) { } else if (strcmp(func_name, "viewtoleft") == 0) {
func = viewtoleft; func = viewtoleft;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "viewtoright") == 0) { } else if (strcmp(func_name, "viewtoright") == 0) {
func = viewtoright; func = viewtoright;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "tagsilent") == 0) { } else if (strcmp(func_name, "tagsilent") == 0) {
func = tagsilent; func = tagsilent;
(*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).ui = 1 << (atoi(arg_value) - 1);
} else if (strcmp(func_name, "tagtoleft") == 0) { } else if (strcmp(func_name, "tagtoleft") == 0) {
func = tagtoleft; func = tagtoleft;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "tagtoright") == 0) { } else if (strcmp(func_name, "tagtoright") == 0) {
func = tagtoright; func = tagtoright;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "killclient") == 0) { } else if (strcmp(func_name, "killclient") == 0) {
func = killclient; func = killclient;
} else if (strcmp(func_name, "centerwin") == 0) { } else if (strcmp(func_name, "centerwin") == 0) {
@ -810,16 +814,20 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
func = togglemaxmizescreen; func = togglemaxmizescreen;
} else if (strcmp(func_name, "viewtoleft_have_client") == 0) { } else if (strcmp(func_name, "viewtoleft_have_client") == 0) {
func = viewtoleft_have_client; func = viewtoleft_have_client;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "viewtoright_have_client") == 0) { } else if (strcmp(func_name, "viewtoright_have_client") == 0) {
func = viewtoright_have_client; func = viewtoright_have_client;
(*arg).i = atoi(arg_value);
} else if (strcmp(func_name, "reload_config") == 0) { } else if (strcmp(func_name, "reload_config") == 0) {
func = reload_config; func = reload_config;
} else if (strcmp(func_name, "tag") == 0) { } else if (strcmp(func_name, "tag") == 0) {
func = tag; func = tag;
(*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).ui = 1 << (atoi(arg_value) - 1);
(*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "view") == 0) { } else if (strcmp(func_name, "view") == 0) {
func = bind_to_view; func = bind_to_view;
(*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).ui = 1 << (atoi(arg_value) - 1);
(*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "toggletag") == 0) { } else if (strcmp(func_name, "toggletag") == 0) {
func = toggletag; func = toggletag;
(*arg).ui = 1 << (atoi(arg_value) - 1); (*arg).ui = 1 << (atoi(arg_value) - 1);
@ -1699,9 +1707,9 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(KeyBinding)); memset(binding, 0, sizeof(KeyBinding));
char mod_str[256], keysym_str[256], func_name[256], char mod_str[256], keysym_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none", arg_value[256] = "0\0", arg_value2[256] = "0\0",
arg_value3[256] = "none", arg_value4[256] = "none", arg_value3[256] = "0\0", arg_value4[256] = "0\0",
arg_value5[256] = "none"; arg_value5[256] = "0\0";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, keysym_str, func_name, arg_value, arg_value2, mod_str, keysym_str, func_name, arg_value, arg_value2,
arg_value3, arg_value4, arg_value5) < 3) { arg_value3, arg_value4, arg_value5) < 3) {
@ -1758,9 +1766,9 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(MouseBinding)); memset(binding, 0, sizeof(MouseBinding));
char mod_str[256], button_str[256], func_name[256], char mod_str[256], button_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none", arg_value[256] = "0\0", arg_value2[256] = "0\0",
arg_value3[256] = "none", arg_value4[256] = "none", arg_value3[256] = "0\0", arg_value4[256] = "0\0",
arg_value5[256] = "none"; arg_value5[256] = "0\0";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, button_str, func_name, arg_value, arg_value2, mod_str, button_str, func_name, arg_value, arg_value2,
arg_value3, arg_value4, arg_value5) < 3) { arg_value3, arg_value4, arg_value5) < 3) {
@ -1817,9 +1825,9 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(AxisBinding)); memset(binding, 0, sizeof(AxisBinding));
char mod_str[256], dir_str[256], func_name[256], char mod_str[256], dir_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none", arg_value[256] = "0\0", arg_value2[256] = "0\0",
arg_value3[256] = "none", arg_value4[256] = "none", arg_value3[256] = "0\0", arg_value4[256] = "0\0",
arg_value5[256] = "none"; arg_value5[256] = "0\0";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, dir_str, func_name, arg_value, arg_value2, mod_str, dir_str, func_name, arg_value, arg_value2,
arg_value3, arg_value4, arg_value5) < 3) { arg_value3, arg_value4, arg_value5) < 3) {
@ -1879,9 +1887,9 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(SwitchBinding)); memset(binding, 0, sizeof(SwitchBinding));
char fold_str[256], func_name[256], char fold_str[256], func_name[256],
arg_value[256] = "none", arg_value2[256] = "none", arg_value[256] = "0\0", arg_value2[256] = "0\0",
arg_value3[256] = "none", arg_value4[256] = "none", arg_value3[256] = "0\0", arg_value4[256] = "0\0",
arg_value5[256] = "none"; arg_value5[256] = "0\0";
if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", if (sscanf(value, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
fold_str, func_name, arg_value, arg_value2, arg_value3, fold_str, func_name, arg_value, arg_value2, arg_value3,
arg_value4, arg_value5) < 3) { arg_value4, arg_value5) < 3) {
@ -1935,9 +1943,9 @@ void parse_config_line(Config *config, const char *line) {
memset(binding, 0, sizeof(GestureBinding)); memset(binding, 0, sizeof(GestureBinding));
char mod_str[256], motion_str[256], fingers_count_str[256], char mod_str[256], motion_str[256], fingers_count_str[256],
func_name[256], arg_value[256] = "none", arg_value2[256] = "none", func_name[256], arg_value[256] = "0\0", arg_value2[256] = "0\0",
arg_value3[256] = "none", arg_value4[256] = "none", arg_value3[256] = "0\0", arg_value4[256] = "0\0",
arg_value5[256] = "none"; arg_value5[256] = "0\0";
if (sscanf(value, if (sscanf(value,
"%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]", "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",
mod_str, motion_str, fingers_count_str, func_name, arg_value, mod_str, motion_str, fingers_count_str, func_name, arg_value,

View file

@ -18,9 +18,9 @@ void bind_to_view(const Arg *arg) {
} }
if (target == 0 || (int)target == INT_MIN) { if (target == 0 || (int)target == INT_MIN) {
view(&(Arg){.ui = ~0 & TAGMASK}, false); view(&(Arg){.ui = ~0 & TAGMASK, .i = arg->i}, false);
} else { } else {
view(&(Arg){.ui = target}, true); view(&(Arg){.ui = target, .i = arg->i}, true);
} }
} }
@ -992,7 +992,7 @@ void tagtoleft(const Arg *arg) {
if (selmon->sel != NULL && if (selmon->sel != NULL &&
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] > 1) { selmon->tagset[selmon->seltags] > 1) {
tag(&(Arg){.ui = selmon->tagset[selmon->seltags] >> 1}); tag(&(Arg){.ui = selmon->tagset[selmon->seltags] >> 1, .i = arg->i});
} }
} }
@ -1000,7 +1000,7 @@ void tagtoright(const Arg *arg) {
if (selmon->sel != NULL && if (selmon->sel != NULL &&
__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 &&
selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
tag(&(Arg){.ui = selmon->tagset[selmon->seltags] << 1}); tag(&(Arg){.ui = selmon->tagset[selmon->seltags] << 1, .i = arg->i});
} }
} }
@ -1194,7 +1194,7 @@ void viewtoleft(const Arg *arg) {
if (!selmon || (target) == selmon->tagset[selmon->seltags]) if (!selmon || (target) == selmon->tagset[selmon->seltags])
return; return;
view(&(Arg){.ui = target & TAGMASK}, true); view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true);
} }
void viewtoright(const Arg *arg) { void viewtoright(const Arg *arg) {
if (selmon->isoverview || selmon->pertag->curtag == 0) { if (selmon->isoverview || selmon->pertag->curtag == 0) {
@ -1209,7 +1209,7 @@ void viewtoright(const Arg *arg) {
return; return;
} }
view(&(Arg){.ui = target & TAGMASK}, true); view(&(Arg){.ui = target & TAGMASK, .i = arg->i}, true);
} }
void viewtoleft_have_client(const Arg *arg) { void viewtoleft_have_client(const Arg *arg) {
@ -1233,7 +1233,7 @@ void viewtoleft_have_client(const Arg *arg) {
} }
if (found) if (found)
view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK}, true); view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK, .i = arg->i}, true);
} }
void viewtoright_have_client(const Arg *arg) { void viewtoright_have_client(const Arg *arg) {
@ -1257,7 +1257,7 @@ void viewtoright_have_client(const Arg *arg) {
} }
if (found) if (found)
view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK}, true); view(&(Arg){.ui = (1 << (n - 1)) & TAGMASK, .i = arg->i}, true);
} }
void zoom(const Arg *arg) { void zoom(const Arg *arg) {

View file

@ -262,7 +262,7 @@ void dwl_ipc_output_set_tags(struct wl_client *client,
return; return;
monitor = ipc_output->mon; monitor = ipc_output->mon;
view_in_mon(&(Arg){.ui = newtags}, true, monitor); view_in_mon(&(Arg){.ui = newtags}, true, monitor, true);
} }
void dwl_ipc_output_quit(struct wl_client *client, void dwl_ipc_output_quit(struct wl_client *client,

View file

@ -654,7 +654,8 @@ static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx,
int sy, void *data); int sy, void *data);
static Client *direction_select(const Arg *arg); static Client *direction_select(const Arg *arg);
static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m); static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
bool changefocus);
static void buffer_set_effect(Client *c, BufferData buffer_data); static void buffer_set_effect(Client *c, BufferData buffer_data);
static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer,
@ -1236,7 +1237,7 @@ void applyrules(Client *c) {
!(c->mon == selmon && c->tags & c->mon->tagset[c->mon->seltags]) && !(c->mon == selmon && c->tags & c->mon->tagset[c->mon->seltags]) &&
!c->isopensilent && !c->istagsilent) { !c->isopensilent && !c->istagsilent) {
c->animation.tag_from_rule = true; c->animation.tag_from_rule = true;
view_in_mon(&(Arg){.ui = c->tags}, true, c->mon); view_in_mon(&(Arg){.ui = c->tags}, true, c->mon, true);
} }
setfullscreen(c, fullscreen_state_backup); setfullscreen(c, fullscreen_state_backup);
@ -4945,7 +4946,7 @@ void tag_client(const Arg *arg, Client *target_client) {
clear_fullscreen_flag(fc); clear_fullscreen_flag(fc);
} }
} }
view(&(Arg){.ui = arg->ui}, false); view(&(Arg){.ui = arg->ui, .i = arg->i}, false);
} else { } else {
view(arg, false); view(arg, false);
@ -5395,7 +5396,8 @@ urgent(struct wl_listener *listener, void *data) {
} }
} }
void view_in_mon(const Arg *arg, bool want_animation, Monitor *m) { void view_in_mon(const Arg *arg, bool want_animation, Monitor *m,
bool changefocus) {
unsigned int i, tmptag; unsigned int i, tmptag;
if (!m || (arg->ui != (~0 & TAGMASK) && m->isoverview)) { if (!m || (arg->ui != (~0 & TAGMASK) && m->isoverview)) {
@ -5442,13 +5444,25 @@ void view_in_mon(const Arg *arg, bool want_animation, Monitor *m) {
toggleseltags: toggleseltags:
focusclient(focustop(m), 1); if (changefocus)
focusclient(focustop(m), 1);
arrange(m, want_animation); arrange(m, want_animation);
printstatus(); printstatus();
} }
void view(const Arg *arg, bool want_animation) { void view(const Arg *arg, bool want_animation) {
view_in_mon(arg, want_animation, selmon); Monitor *m, *record_mon;
if (arg->i) {
record_mon = selmon;
view_in_mon(arg, want_animation, record_mon, true);
wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled || m == record_mon)
continue;
view_in_mon(arg, want_animation, m, false);
}
} else {
view_in_mon(arg, want_animation, selmon, true);
}
} }
void virtualkeyboard(struct wl_listener *listener, void *data) { void virtualkeyboard(struct wl_listener *listener, void *data) {