feat: add dwindle_split_horizontal and dwindle_split_vertical

This commit is contained in:
DreamMaoMao 2026-05-17 09:53:58 +08:00
parent 65c9ac6dd2
commit c822f5d5b9
3 changed files with 45 additions and 9 deletions

View file

@ -1226,6 +1226,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
func = toggle_all_floating;
} else if (strcmp(func_name, "dwindle_toggle_split_direction") == 0) {
func = dwindle_toggle_split_direction;
} else if (strcmp(func_name, "dwindle_split_horizontal") == 0) {
func = dwindle_split_horizontal;
} else if (strcmp(func_name, "dwindle_split_vertical") == 0) {
func = dwindle_split_vertical;
} else {
return NULL;
}

View file

@ -71,4 +71,6 @@ int32_t enable_monitor(const Arg *arg);
int32_t toggle_monitor(const Arg *arg);
int32_t scroller_stack(const Arg *arg);
int32_t toggle_all_floating(const Arg *arg);
int32_t dwindle_toggle_split_direction(const Arg *arg);
int32_t dwindle_toggle_split_direction(const Arg *arg);
int32_t dwindle_split_horizontal(const Arg *arg);
int32_t dwindle_split_vertical(const Arg *arg);

View file

@ -1923,13 +1923,7 @@ int32_t toggle_all_floating(const Arg *arg) {
return 0;
}
int32_t dwindle_toggle_split_direction(const Arg *arg) {
if (!selmon || !selmon->sel)
return 0;
Client *c = selmon->sel;
if (!c || !c->mon || c->isfloating)
return 0;
int32_t dwindle_set_split_direction(Client *c, bool istoggle, bool horizontal) {
const Layout *layout = c->mon->pertag->ltidxs[c->mon->pertag->curtag];
@ -1942,8 +1936,44 @@ int32_t dwindle_toggle_split_direction(const Arg *arg) {
if (!leaf)
return 0;
leaf->custom_leaf_split_h = !leaf->custom_leaf_split_h;
if (istoggle) {
leaf->custom_leaf_split_h = !leaf->custom_leaf_split_h;
} else if (horizontal) {
leaf->custom_leaf_split_h = true;
} else {
leaf->custom_leaf_split_h = false;
}
bool hit_no_border = check_hit_no_border(c);
apply_split_border(c, hit_no_border);
return 0;
}
int32_t dwindle_toggle_split_direction(const Arg *arg) {
if (!selmon || !selmon->sel)
return 0;
Client *c = selmon->sel;
if (!c || !c->mon || c->isfloating)
return 0;
return dwindle_set_split_direction(selmon->sel, true, false);
}
int32_t dwindle_split_horizontal(const Arg *arg) {
if (!selmon || !selmon->sel)
return 0;
Client *c = selmon->sel;
if (!c || !c->mon || c->isfloating)
return 0;
return dwindle_set_split_direction(selmon->sel, false, true);
}
int32_t dwindle_split_vertical(const Arg *arg) {
if (!selmon || !selmon->sel)
return 0;
Client *c = selmon->sel;
if (!c || !c->mon || c->isfloating)
return 0;
return dwindle_set_split_direction(selmon->sel, false, false);
}