feat: opt-in config field to have typical dwindle tiling

This commit is contained in:
ernestoCruz05 2026-05-09 12:14:57 +01:00 committed by DreamMaoMao
parent b0bd70d225
commit bb1443a063
3 changed files with 46 additions and 1 deletions

View file

@ -432,6 +432,11 @@ void client_set_drop_area(Client *c) {
struct wlr_box drop_box;
const Layout *cur_layout =
c->mon ? c->mon->pertag->ltidxs[c->mon->pertag->curtag] : NULL;
bool dwindle_familiar = cur_layout && cur_layout->id == DWINDLE &&
config.dwindle_drop_simple_split;
// 中心区域x和y都在30%~70%之间 → 无方向
if (rel_x > client_width * 0.3 && rel_x < client_width * 0.7 &&
rel_y > client_height * 0.3 && rel_y < client_height * 0.7) {
@ -440,6 +445,40 @@ void client_set_drop_area(Client *c) {
drop_box.width = client_width * 0.4;
drop_box.height = client_height * 0.4;
drop_direction = UNDIR;
} else if (dwindle_familiar) {
// Mirror dwindle_assign's split_h = (aw >= ah) rule so the preview
// matches the auto-rotated split that dwindle will produce.
bool split_h = c->geom.width >= c->geom.height;
float ratio = config.dwindle_split_ratio;
if (split_h) {
if (rel_x < client_width * 0.5) {
drop_direction = LEFT;
drop_box.x = bw;
drop_box.y = bw;
drop_box.width = (int32_t)(client_width * ratio);
drop_box.height = client_height;
} else {
drop_direction = RIGHT;
drop_box.x = bw + (int32_t)(client_width * ratio);
drop_box.y = bw;
drop_box.width = client_width - (int32_t)(client_width * ratio);
drop_box.height = client_height;
}
} else {
if (rel_y < client_height * 0.5) {
drop_direction = UP;
drop_box.x = bw;
drop_box.y = bw;
drop_box.width = client_width;
drop_box.height = (int32_t)(client_height * ratio);
} else {
drop_direction = DOWN;
drop_box.x = bw;
drop_box.y = bw + (int32_t)(client_height * ratio);
drop_box.width = client_width;
drop_box.height = client_height - (int32_t)(client_height * ratio);
}
}
} else {
// 否则根据到各边的距离决定方向
double dist_left = rel_x;