Merge pull request #908 from ernestoCruz05/dwindle

feat: opt-in config field to have typical dwindle tiling
This commit is contained in:
DreamMaoMao 2026-05-09 21:20:12 +08:00
commit d132f955c4
3 changed files with 46 additions and 1 deletions

View file

@ -538,6 +538,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) {
@ -546,6 +551,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;

View file

@ -248,6 +248,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;
@ -1633,6 +1634,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) {
@ -3205,6 +3208,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);
@ -3351,6 +3356,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;

View file

@ -2229,7 +2229,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;
}