mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-14 21:38:23 -04:00
feat: opt-in config field to have typical dwindle tiling
This commit is contained in:
parent
b0bd70d225
commit
bb1443a063
3 changed files with 46 additions and 1 deletions
|
|
@ -432,6 +432,11 @@ void client_set_drop_area(Client *c) {
|
||||||
|
|
||||||
struct wlr_box drop_box;
|
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%之间 → 无方向
|
// 中心区域:x和y都在30%~70%之间 → 无方向
|
||||||
if (rel_x > client_width * 0.3 && rel_x < client_width * 0.7 &&
|
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) {
|
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.width = client_width * 0.4;
|
||||||
drop_box.height = client_height * 0.4;
|
drop_box.height = client_height * 0.4;
|
||||||
drop_direction = UNDIR;
|
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 {
|
} else {
|
||||||
// 否则根据到各边的距离决定方向
|
// 否则根据到各边的距离决定方向
|
||||||
double dist_left = rel_x;
|
double dist_left = rel_x;
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,7 @@ typedef struct {
|
||||||
int32_t dwindle_preserve_split;
|
int32_t dwindle_preserve_split;
|
||||||
int32_t dwindle_smart_split;
|
int32_t dwindle_smart_split;
|
||||||
int32_t dwindle_smart_resize;
|
int32_t dwindle_smart_resize;
|
||||||
|
int32_t dwindle_drop_simple_split;
|
||||||
float dwindle_split_ratio;
|
float dwindle_split_ratio;
|
||||||
|
|
||||||
uint32_t hotarea_size;
|
uint32_t hotarea_size;
|
||||||
|
|
@ -1576,6 +1577,8 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
config->dwindle_smart_split = atoi(value);
|
config->dwindle_smart_split = atoi(value);
|
||||||
} else if (strcmp(key, "dwindle_smart_resize") == 0) {
|
} else if (strcmp(key, "dwindle_smart_resize") == 0) {
|
||||||
config->dwindle_smart_resize = atoi(value);
|
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) {
|
} else if (strcmp(key, "dwindle_split_ratio") == 0) {
|
||||||
config->dwindle_split_ratio = atof(value);
|
config->dwindle_split_ratio = atof(value);
|
||||||
} else if (strcmp(key, "hotarea_size") == 0) {
|
} else if (strcmp(key, "hotarea_size") == 0) {
|
||||||
|
|
@ -3118,6 +3121,8 @@ void override_config(void) {
|
||||||
CLAMP_INT(config.dwindle_preserve_split, 0, 1);
|
CLAMP_INT(config.dwindle_preserve_split, 0, 1);
|
||||||
config.dwindle_smart_split = CLAMP_INT(config.dwindle_smart_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_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 =
|
config.dwindle_split_ratio =
|
||||||
CLAMP_FLOAT(config.dwindle_split_ratio, 0.05f, 0.95f);
|
CLAMP_FLOAT(config.dwindle_split_ratio, 0.05f, 0.95f);
|
||||||
config.hotarea_size = CLAMP_INT(config.hotarea_size, 1, 1000);
|
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_preserve_split = 0;
|
||||||
config.dwindle_smart_split = 0;
|
config.dwindle_smart_split = 0;
|
||||||
config.dwindle_smart_resize = 0;
|
config.dwindle_smart_resize = 0;
|
||||||
|
config.dwindle_drop_simple_split = 0;
|
||||||
config.dwindle_split_ratio = 0.5f;
|
config.dwindle_split_ratio = 0.5f;
|
||||||
|
|
||||||
config.log_level = WLR_ERROR;
|
config.log_level = WLR_ERROR;
|
||||||
|
|
|
||||||
|
|
@ -2247,7 +2247,7 @@ void place_drag_tile_client(Client *c) {
|
||||||
closest->drop_direction == RIGHT);
|
closest->drop_direction == RIGHT);
|
||||||
dwindle_insert(&c->mon->pertag->dwindle_root[tag], c, closest,
|
dwindle_insert(&c->mon->pertag->dwindle_root[tag], c, closest,
|
||||||
config.dwindle_split_ratio, insert_before, split_h,
|
config.dwindle_split_ratio, insert_before, split_h,
|
||||||
true);
|
!config.dwindle_drop_simple_split);
|
||||||
setfloating(c, 0);
|
setfloating(c, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue