From bb1443a063ad8d44cca1add8cba26e5ccfe66ece Mon Sep 17 00:00:00 2001 From: ernestoCruz05 Date: Sat, 9 May 2026 12:14:57 +0100 Subject: [PATCH] feat: opt-in config field to have typical dwindle tiling --- src/animation/client.h | 39 +++++++++++++++++++++++++++++++++++++++ src/config/parse_config.h | 6 ++++++ src/mango.c | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/animation/client.h b/src/animation/client.h index fbda2bc3..74e25457 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -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; diff --git a/src/config/parse_config.h b/src/config/parse_config.h index e10b69b9..fb3f2e95 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -243,6 +243,7 @@ typedef struct { int32_t dwindle_preserve_split; int32_t dwindle_smart_split; int32_t dwindle_smart_resize; + int32_t dwindle_drop_simple_split; float dwindle_split_ratio; uint32_t hotarea_size; @@ -1576,6 +1577,8 @@ bool parse_option(Config *config, char *key, char *value) { config->dwindle_smart_split = atoi(value); } else if (strcmp(key, "dwindle_smart_resize") == 0) { config->dwindle_smart_resize = atoi(value); + } else if (strcmp(key, "dwindle_drop_simple_split") == 0) { + config->dwindle_drop_simple_split = atoi(value); } else if (strcmp(key, "dwindle_split_ratio") == 0) { config->dwindle_split_ratio = atof(value); } else if (strcmp(key, "hotarea_size") == 0) { @@ -3118,6 +3121,8 @@ void override_config(void) { CLAMP_INT(config.dwindle_preserve_split, 0, 1); config.dwindle_smart_split = CLAMP_INT(config.dwindle_smart_split, 0, 1); config.dwindle_smart_resize = CLAMP_INT(config.dwindle_smart_resize, 0, 1); + config.dwindle_drop_simple_split = + CLAMP_INT(config.dwindle_drop_simple_split, 0, 1); config.dwindle_split_ratio = CLAMP_FLOAT(config.dwindle_split_ratio, 0.05f, 0.95f); config.hotarea_size = CLAMP_INT(config.hotarea_size, 1, 1000); @@ -3239,6 +3244,7 @@ void set_value_default() { config.dwindle_preserve_split = 0; config.dwindle_smart_split = 0; config.dwindle_smart_resize = 0; + config.dwindle_drop_simple_split = 0; config.dwindle_split_ratio = 0.5f; config.log_level = WLR_ERROR; diff --git a/src/mango.c b/src/mango.c index 7222d6db..0585abb5 100644 --- a/src/mango.c +++ b/src/mango.c @@ -2247,7 +2247,7 @@ void place_drag_tile_client(Client *c) { closest->drop_direction == RIGHT); dwindle_insert(&c->mon->pertag->dwindle_root[tag], c, closest, config.dwindle_split_ratio, insert_before, split_h, - true); + !config.dwindle_drop_simple_split); setfloating(c, 0); return; }