feat: add option to set default scratchpad size

This commit is contained in:
DreamMaoMao 2025-07-04 12:29:49 +08:00
parent bc85232985
commit 263e2e4260
4 changed files with 22 additions and 4 deletions

View file

@ -106,6 +106,8 @@ gappih=5
gappiv=5 gappiv=5
gappoh=10 gappoh=10
gappov=10 gappov=10
scratchpad_width_ratio=0.8
scratchpad_height_ratio=0.9
borderpx=4 borderpx=4
rootcolor=0x201b14ff rootcolor=0x201b14ff
bordercolor=0x444444ff bordercolor=0x444444ff

View file

@ -230,6 +230,8 @@ typedef struct {
unsigned int gappoh; unsigned int gappoh;
unsigned int gappov; unsigned int gappov;
unsigned int borderpx; unsigned int borderpx;
float scratchpad_width_ratio;
float scratchpad_height_ratio;
float rootcolor[4]; float rootcolor[4];
float bordercolor[4]; float bordercolor[4];
float focuscolor[4]; float focuscolor[4];
@ -1191,6 +1193,10 @@ void parse_config_line(Config *config, const char *line) {
config->gappoh = atoi(value); config->gappoh = atoi(value);
} else if (strcmp(key, "gappov") == 0) { } else if (strcmp(key, "gappov") == 0) {
config->gappov = atoi(value); config->gappov = atoi(value);
} else if (strcmp(key, "scratchpad_width_ratio") == 0) {
config->scratchpad_width_ratio = atof(value);
} else if (strcmp(key, "scratchpad_height_ratio") == 0) {
config->scratchpad_height_ratio = atof(value);
} else if (strcmp(key, "borderpx") == 0) { } else if (strcmp(key, "borderpx") == 0) {
config->borderpx = atoi(value); config->borderpx = atoi(value);
} else if (strcmp(key, "rootcolor") == 0) { } else if (strcmp(key, "rootcolor") == 0) {
@ -2194,6 +2200,10 @@ void override_config(void) {
gappiv = CLAMP_INT(config.gappiv, 0, 1000); gappiv = CLAMP_INT(config.gappiv, 0, 1000);
gappoh = CLAMP_INT(config.gappoh, 0, 1000); gappoh = CLAMP_INT(config.gappoh, 0, 1000);
gappov = CLAMP_INT(config.gappov, 0, 1000); gappov = CLAMP_INT(config.gappov, 0, 1000);
scratchpad_width_ratio =
CLAMP_FLOAT(config.scratchpad_width_ratio, 0.1f, 1.0f);
scratchpad_height_ratio =
CLAMP_FLOAT(config.scratchpad_height_ratio, 0.1f, 1.0f);
borderpx = CLAMP_INT(config.borderpx, 0, 200); borderpx = CLAMP_INT(config.borderpx, 0, 200);
smartgaps = CLAMP_INT(config.smartgaps, 0, 1); smartgaps = CLAMP_INT(config.smartgaps, 0, 1);
@ -2282,6 +2292,8 @@ void set_value_default() {
config.gappoh = config.gappoh =
gappoh; /* horiz outer gap between windows and screen edge */ gappoh; /* horiz outer gap between windows and screen edge */
config.gappov = gappov; /* vert outer gap between windows and screen edge */ config.gappov = gappov; /* vert outer gap between windows and screen edge */
config.scratchpad_width_ratio = scratchpad_width_ratio;
config.scratchpad_height_ratio = scratchpad_height_ratio;
config.scroller_structs = scroller_structs; config.scroller_structs = scroller_structs;
config.scroller_default_proportion = scroller_default_proportion; config.scroller_default_proportion = scroller_default_proportion;

View file

@ -48,6 +48,8 @@ unsigned int gappih = 5; /* horiz inner gap between windows */
unsigned int gappiv = 5; /* vert inner gap between windows */ unsigned int gappiv = 5; /* vert inner gap between windows */
unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
float scratchpad_width_ratio = 0.8;
float scratchpad_height_ratio = 0.9;
int scroller_structs = 20; int scroller_structs = 20;
float scroller_default_proportion = 0.9; float scroller_default_proportion = 0.9;

View file

@ -1695,10 +1695,12 @@ void show_scratchpad(Client *c) {
/* return if fullscreen */ /* return if fullscreen */
if (!c->isfloating) { if (!c->isfloating) {
setfloating(c, 1); setfloating(c, 1);
c->geom.width = c->scratchpad_geom.width ? c->scratchpad_geom.width c->geom.width = c->scratchpad_geom.width
: c->mon->w.width * 0.7; ? c->scratchpad_geom.width
c->geom.height = c->scratchpad_geom.height ? c->scratchpad_geom.height : c->mon->w.width * scratchpad_width_ratio;
: c->mon->w.height * 0.8; c->geom.height = c->scratchpad_geom.height
? c->scratchpad_geom.height
: c->mon->w.height * scratchpad_height_ratio;
// 重新计算居中的坐标 // 重新计算居中的坐标
c->oldgeom = c->geom = c->animainit_geom = c->animation.current = c->oldgeom = c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c, c->geom, 0, 0); setclient_coordinate_center(c, c->geom, 0, 0);