From 407c9d74a42763f56817af2ee4821c92e9eba4f7 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Fri, 14 Nov 2025 15:39:04 +0800 Subject: [PATCH] feat: add windowrule option scroller_proportion_single --- src/config/parse_config.h | 4 ++++ src/layout/horizontal.h | 9 +++++++-- src/layout/vertical.h | 10 ++++++++-- src/mango.c | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 6358083..074660b 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -90,6 +90,7 @@ typedef struct { int noblur; float focused_opacity; float unfocused_opacity; + float scroller_proportion_single; uint32_t passmod; xkb_keysym_t keysym; KeyBinding globalkeybinding; @@ -1679,6 +1680,7 @@ void parse_option(Config *config, char *key, char *value) { // float rule value, relay to a client property rule->focused_opacity = 0; rule->unfocused_opacity = 0; + rule->scroller_proportion_single = 0.0f; rule->scroller_proportion = 0; // special rule value,not directly set to client property @@ -1750,6 +1752,8 @@ void parse_option(Config *config, char *key, char *value) { rule->isunglobal = atoi(val); } else if (strcmp(key, "isglobal") == 0) { rule->isglobal = atoi(val); + } else if (strcmp(key, "scroller_proportion_single") == 0) { + rule->scroller_proportion_single = atof(val); } else if (strcmp(key, "unfocused_opacity") == 0) { rule->unfocused_opacity = atof(val); } else if (strcmp(key, "focused_opacity") == 0) { diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 178ae9e..934dc13 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -192,6 +192,7 @@ void deck(Monitor *m) { // 滚动布局 void scroller(Monitor *m) { unsigned int i, n, j; + float single_proportion = 1.0; Client *c = NULL, *root_client = NULL; Client **tempClients = NULL; // 初始化为 NULL @@ -233,9 +234,13 @@ void scroller(Monitor *m) { if (n == 1 && !scroller_ignore_proportion_single) { c = tempClients[0]; + + single_proportion = c->scroller_proportion_single > 0.0f + ? c->scroller_proportion_single + : scroller_default_proportion_single; + target_geom.height = m->w.height - 2 * cur_gappov; - target_geom.width = - (m->w.width - 2 * cur_gappoh) * scroller_default_proportion_single; + target_geom.width = (m->w.width - 2 * cur_gappoh) * single_proportion; target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2; target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; resize(c, target_geom, 0); diff --git a/src/layout/vertical.h b/src/layout/vertical.h index 6ae21a6..46ca3b6 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -157,6 +157,8 @@ void vertical_deck(Monitor *m) { void vertical_scroller(Monitor *m) { unsigned int i, n, j; + float single_proportion = 1.0; + Client *c = NULL, *root_client = NULL; Client **tempClients = NULL; struct wlr_box target_geom; @@ -194,9 +196,13 @@ void vertical_scroller(Monitor *m) { if (n == 1 && !scroller_ignore_proportion_single) { c = tempClients[0]; + + single_proportion = c->scroller_proportion_single > 0.0f + ? c->scroller_proportion_single + : scroller_default_proportion_single; + target_geom.width = m->w.width - 2 * cur_gappoh; - target_geom.height = - (m->w.height - 2 * cur_gappov) * scroller_default_proportion_single; + target_geom.height = (m->w.height - 2 * cur_gappov) * single_proportion; target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2; target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; resize(c, target_geom, 0); diff --git a/src/mango.c b/src/mango.c index 7bb3bb2..601c36f 100644 --- a/src/mango.c +++ b/src/mango.c @@ -376,6 +376,7 @@ struct Client { int tearing_hint; int force_tearing; int allow_shortcuts_inhibit; + float scroller_proportion_single; }; typedef struct { @@ -1173,6 +1174,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) { APPLY_INT_PROP(c, r, allow_shortcuts_inhibit); APPLY_FLOAT_PROP(c, r, scroller_proportion); + APPLY_FLOAT_PROP(c, r, scroller_proportion_single); APPLY_FLOAT_PROP(c, r, focused_opacity); APPLY_FLOAT_PROP(c, r, unfocused_opacity); @@ -3623,6 +3625,7 @@ void init_client_properties(Client *c) { c->force_maximize = 0; c->force_tearing = 0; c->allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE; + c->scroller_proportion_single = 0.0f; } void // old fix to 0.5