From 1d616d54ff79f4bf70b04d1dbd28c88df1cc3bd5 Mon Sep 17 00:00:00 2001 From: Alessio Molinari Date: Wed, 21 Jan 2026 22:09:14 +0100 Subject: [PATCH] feat(window_rule): support width/height as fractions in window rules. --- src/config/parse_config.h | 8 ++++---- src/mango.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 15857ae..b2229a0 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -80,8 +80,8 @@ typedef struct { const char *monitor; int32_t offsetx; int32_t offsety; - int32_t width; - int32_t height; + float width; + float height; int32_t nofocus; int32_t nofadein; int32_t nofadeout; @@ -1805,9 +1805,9 @@ void parse_option(Config *config, char *key, char *value) { } else if (strcmp(key, "no_force_center") == 0) { rule->no_force_center = atoi(val); } else if (strcmp(key, "width") == 0) { - rule->width = atoi(val); + rule->width = atof(val); } else if (strcmp(key, "height") == 0) { - rule->height = atoi(val); + rule->height = atof(val); } else if (strcmp(key, "isnoborder") == 0) { rule->isnoborder = atoi(val); } else if (strcmp(key, "isnoshadow") == 0) { diff --git a/src/mango.c b/src/mango.c index f61e27f..80b70e4 100644 --- a/src/mango.c +++ b/src/mango.c @@ -1360,10 +1360,14 @@ void applyrules(Client *c) { // set geometry of floating client - if (r->width > 0) + if (r->width > 1) c->float_geom.width = r->width; - if (r->height > 0) + else + c->float_geom.width = round(mon->m.width * r->width); + if (r->height > 1) c->float_geom.height = r->height; + else + c->float_geom.height = round(mon->m.height * r->height); if (r->width > 0 || r->height > 0) { c->iscustomsize = 1;