feat: support group

This commit is contained in:
DreamMaoMao 2026-06-20 18:44:28 +08:00
parent 0fc7559c3c
commit d1cab2c4b7
14 changed files with 483 additions and 233 deletions

View file

@ -2,6 +2,7 @@ int32_t minimized(const Arg *arg);
int32_t restore_minimized(const Arg *arg);
int32_t toggle_scratchpad(const Arg *arg);
int32_t focusdir(const Arg *arg);
int32_t groupjoin(const Arg *arg);
int32_t toggleoverview(const Arg *arg);
int32_t togglejump(const Arg *arg);
int32_t set_proportion(const Arg *arg);
@ -38,6 +39,7 @@ int32_t toggleglobal(const Arg *arg);
int32_t incnmaster(const Arg *arg);
int32_t focusmon(const Arg *arg);
int32_t focusstack(const Arg *arg);
int32_t groupfocus(const Arg *arg);
int32_t chvt(const Arg *arg);
int32_t reload_config(const Arg *arg);
int32_t smartmovewin(const Arg *arg);

View file

@ -156,6 +156,48 @@ int32_t focusdir(const Arg *arg) {
return 0;
}
int32_t groupjoin(const Arg *arg) {
if (!selmon)
return 0;
Client *need_join_client = arg->tc ? arg->tc : selmon->sel;
if (!need_join_client)
return 0;
if (need_join_client->group_next || need_join_client->group_prev) {
return 0;
}
Client *need_replace_client = NULL;
need_replace_client = direction_select(arg);
if (!need_replace_client ||
need_replace_client->mon != need_join_client->mon)
return 0;
if (!need_join_client->group_next && !need_join_client->group_prev) {
if (!need_replace_client->group_prev &&
!need_replace_client->group_next) {
need_replace_client->isgroupfocusing = true;
}
need_join_client->group_next = need_replace_client;
if (need_replace_client->group_prev) {
need_replace_client->group_prev->group_next = need_join_client;
}
need_join_client->group_prev = need_replace_client->group_prev;
need_replace_client->group_prev = need_join_client;
client_focus_group_member(need_join_client);
arrange(need_join_client->mon, false, false);
return 0;
}
return 0;
}
int32_t focuslast(const Arg *arg) {
Client *c = NULL;
Client *tc = NULL;
@ -261,6 +303,31 @@ int32_t focusstack(const Arg *arg) {
return 0;
}
int32_t groupfocus(const Arg *arg) {
Client *c = arg->tc ? arg->tc : selmon->sel;
if (!c)
return 0;
if (!c->group_prev && !c->group_next) {
return 0;
}
Client *tc = NULL;
if (arg->i == NEXT) {
tc = c->group_next;
} else {
tc = c->group_prev;
}
if (!tc)
return 0;
client_focus_group_member(tc);
arrange(tc->mon, false, false);
return 0;
}
int32_t incnmaster(const Arg *arg) {
if (!arg || !selmon)
return 0;