From 7f32adbdd96d1055e1c7079b39b773257ec7ac8b Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 5 Aug 2025 21:04:05 +0800 Subject: [PATCH] feat: add isnosizehit option to windowrule --- src/animation/client.h | 3 ++- src/config/parse_config.h | 4 ++++ src/mango.c | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/animation/client.h b/src/animation/client.h index c5105f4..9e8a3cd 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -921,7 +921,8 @@ void resize(Client *c, struct wlr_box geo, int interact) { bbox); // 去掉这个推荐的窗口大小,因为有时推荐的窗口特别大导致平铺异常 } - if (!c->ismaxmizescreen && !c->isfullscreen && c->isfloating) { + if (!c->isnosizehint && !c->ismaxmizescreen && !c->isfullscreen && + c->isfloating) { client_set_size_bound(c); } diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 4f3a533..fe8aca8 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -50,6 +50,7 @@ typedef struct { int isunglobal; int isglobal; int isoverlay; + int isnosizehint; const char *monitor; int offsetx; int offsety; @@ -1415,6 +1416,7 @@ void parse_config_line(Config *config, const char *line) { rule->isunglobal = -1; rule->isglobal = -1; rule->isoverlay = -1; + rule->isnosizehint = -1; rule->isterm = -1; rule->noswallow = -1; rule->noblur = -1; @@ -1497,6 +1499,8 @@ void parse_config_line(Config *config, const char *line) { rule->focused_opacity = atof(val); } else if (strcmp(key, "isoverlay") == 0) { rule->isoverlay = atoi(val); + } else if (strcmp(key, "isnosizehint") == 0) { + rule->isnosizehint = atoi(val); } else if (strcmp(key, "isterm") == 0) { rule->isterm = atoi(val); } else if (strcmp(key, "noswallow") == 0) { diff --git a/src/mango.c b/src/mango.c index 5f11604..61909d0 100644 --- a/src/mango.c +++ b/src/mango.c @@ -265,7 +265,7 @@ struct Client { unsigned int configure_serial; struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; int isfloating, isurgent, isfullscreen, isfakefullscreen, - need_float_size_reduce, isminied, isoverlay; + need_float_size_reduce, isminied, isoverlay, isnosizehint; int ismaxmizescreen; int overview_backup_bw; int fullscreen_backup_x, fullscreen_backup_y, fullscreen_backup_w, @@ -1042,6 +1042,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) { APPLY_INT_PROP(c, r, isnamedscratchpad); APPLY_INT_PROP(c, r, isglobal); APPLY_INT_PROP(c, r, isoverlay); + APPLY_INT_PROP(c, r, isnosizehint); APPLY_INT_PROP(c, r, isunglobal); APPLY_INT_PROP(c, r, scratchpad_width); APPLY_INT_PROP(c, r, scratchpad_height); @@ -1077,7 +1078,9 @@ int applyrulesgeom(Client *c) { c->geom.width = r->width > 0 ? r->width : c->geom.width; c->geom.height = r->height > 0 ? r->height : c->geom.height; - client_set_size_bound(c); + + if (!c->isnosizehint) + client_set_size_bound(c); // 重新计算居中的坐标 if (r->offsetx != 0 || r->offsety != 0 || r->width > 0 || r->height > 0) @@ -1136,7 +1139,8 @@ void applyrules(Client *c) { if (r->height > 0) c->geom.height = r->height; - client_set_size_bound(c); + if (!c->isnosizehint) + client_set_size_bound(c); if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) { hit_rule_pos = true;