From 20f05bcdcc49b3747784f410a72e5d8211061a52 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 5 May 2025 11:55:27 +0800 Subject: [PATCH] feat: add window rule scratch_width, scratch_height --- config.conf | 2 ++ src/config/parse_config.h | 8 ++++++++ src/maomao.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/config.conf b/config.conf index eb0fade..fade1a1 100644 --- a/config.conf +++ b/config.conf @@ -122,6 +122,8 @@ tags=id:9,layout_name:tile # nnoswallow : type-num(0 or 1) -- if enable, this window wll not replace isterm window when it was open by isterm window # globalkeybinding: type-string(for example-- alt-l or alt+super-l) # isopensilent: type-num(0 or 1) -- open but not focus it +# scratch_width : type-num(0-9999) -- width of window when it become scratchpad window +# scratch_height : type-num(0-9999) -- height of window when it become scratchpad window # example # windowrule=isfloating:1,appid:yesplaymusic diff --git a/src/config/parse_config.h b/src/config/parse_config.h index cdab7c0..7f547f3 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -34,6 +34,8 @@ typedef struct { int height; int isterm; int noswallow; + int scratch_width; + int scratch_height; uint32_t passmod; xkb_keysym_t keysym; KeyBinding globalkeybinding; @@ -935,6 +937,8 @@ void parse_config_line(Config *config, const char *line) { rule->monitor = -1; rule->offsetx = 0; rule->offsety = 0; + rule->scratch_width = 0; + rule->scratch_height = 0; rule->width = -1; rule->height = -1; rule->animation_type_open = NULL; @@ -971,6 +975,10 @@ void parse_config_line(Config *config, const char *line) { rule->offsetx = atoi(val); } else if (strcmp(key, "offsety") == 0) { rule->offsety = atoi(val); + } else if (strcmp(key, "scratch_width") == 0) { + rule->scratch_width = atoi(val); + } else if (strcmp(key, "scratch_height") == 0) { + rule->scratch_height = atoi(val); } else if (strcmp(key, "width") == 0) { rule->width = atoi(val); } else if (strcmp(key, "height") == 0) { diff --git a/src/maomao.c b/src/maomao.c index e41d669..a881981 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -1701,6 +1701,8 @@ applyrules(Client *c) { strstr(title, r->title))) { c->isterm = r->isterm > 0 ? r->isterm : c->isterm; c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow; + c->scratch_geom.width = r->scratch_width > 0 ? r->scratch_width : c->scratch_geom.width; + c->scratch_geom.height = r->scratch_height > 0 ? r->scratch_height : c->scratch_geom.height; c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating; c->isfullscreen = r->isfullscreen > 0 ? r->isfullscreen : c->isfullscreen; c->animation_type_open = r->animation_type_open == NULL