From ea03ba6c49b3df81d7f30a517a6f0ecb3a0af855 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 1 Jun 2025 21:41:14 +0800 Subject: [PATCH] feat: winrule option no_force_center --- src/config/parse_config.h | 6 +++++- src/maomao.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 917df96..daed654 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -37,6 +37,7 @@ typedef struct { int width; int height; int nofadein; + int no_force_center; int isterm; int noswallow; int scratchpad_width; @@ -1101,6 +1102,7 @@ void parse_config_line(Config *config, const char *line) { rule->offsetx = 0; rule->offsety = 0; rule->nofadein = 0; + rule->no_force_center = 0; rule->scratchpad_width = 0; rule->scratchpad_height = 0; rule->width = 0; @@ -1144,7 +1146,9 @@ void parse_config_line(Config *config, const char *line) { rule->offsety = atoi(val); } else if (strcmp(key, "nofadein") == 0) { rule->nofadein = atoi(val); - } else if (strcmp(key, "scratchpad_width") == 0) { + } else if (strcmp(key, "no_force_center") == 0) { + rule->no_force_center = atoi(val); + } else if (strcmp(key, "scratchpad_width") == 0) { rule->scratchpad_width = atoi(val); } else if (strcmp(key, "scratchpad_height") == 0) { rule->scratchpad_height = atoi(val); diff --git a/src/maomao.c b/src/maomao.c index 16964b7..79e2b3e 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -277,6 +277,7 @@ struct Client { bool drag_to_tile; bool fake_no_border; int nofadein; + int no_force_center; }; typedef struct { @@ -1742,8 +1743,14 @@ setclient_coordinate_center(Client *c, struct wlr_box geom, int offsetx, unsigned int cbw = check_hit_no_border(c) ? c->bw : 0; - tempbox.x = selmon->w.x + (selmon->w.width - geom.width) / 2; - tempbox.y = selmon->w.y + (selmon->w.height - geom.height) / 2; + if(!c->no_force_center) { + tempbox.x = selmon->w.x + (selmon->w.width - geom.width) / 2; + tempbox.y = selmon->w.y + (selmon->w.height - geom.height) / 2; + } else { + tempbox.x = geom.x; + tempbox.y = geom.y; + } + tempbox.width = geom.width; tempbox.height = geom.height; @@ -1843,6 +1850,8 @@ applyrules(Client *c) { c->isterm = r->isterm > 0 ? r->isterm : c->isterm; c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow; c->nofadein = r->nofadein > 0 ? r->nofadein : c->nofadein; + c->no_force_center = r->no_force_center > 0 ? r->no_force_center + : c->no_force_center; c->scratchpad_geom.width = r->scratchpad_width > 0 ? r->scratchpad_width : c->scratchpad_geom.width; @@ -4491,6 +4500,7 @@ mapnotify(struct wl_listener *listener, void *data) { c->drag_to_tile = false; c->fake_no_border = false; c->nofadein = 0; + c->no_force_center = 0; if (new_is_master && selmon && strcmp(selmon->pertag->ltidxs[selmon->pertag->curtag]->name,