feat: add windowrule option scroller_proportion_single

This commit is contained in:
DreamMaoMao
2025-11-14 15:39:04 +08:00
parent 514c916678
commit 407c9d74a4
4 changed files with 22 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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