opt: remove useless scratchpad_width and scratachpad_height

This commit is contained in:
DreamMaoMao 2025-09-06 12:21:22 +08:00
parent 5ba5154ec8
commit a493db63c0
3 changed files with 25 additions and 31 deletions

View file

@ -65,8 +65,6 @@ typedef struct {
int isterm;
int noswallow;
int noblur;
int scratchpad_width;
int scratchpad_height;
float focused_opacity;
float unfocused_opacity;
uint32_t passmod;
@ -1463,8 +1461,6 @@ void parse_config_line(Config *config, const char *line) {
rule->nofadein = -1;
rule->nofadeout = -1;
rule->no_force_center = -1;
rule->scratchpad_width = 0;
rule->scratchpad_height = 0;
rule->focused_opacity = 0;
rule->unfocused_opacity = 0;
rule->width = 0;
@ -1512,10 +1508,6 @@ void parse_config_line(Config *config, const char *line) {
rule->nofadeout = atoi(val);
} else if (strcmp(key, "no_force_center") == 0) {
rule->no_force_center = atoi(val);
} else if (strcmp(key, "scratchpad_width") == 0) {
rule->scratchpad_width = atoi(val);
} else if (strcmp(key, "scratchpad_height") == 0) {
rule->scratchpad_height = atoi(val);
} else if (strcmp(key, "width") == 0) {
rule->width = atoi(val);
} else if (strcmp(key, "height") == 0) {

View file

@ -343,6 +343,7 @@ void movewin(const Arg *arg) {
break;
}
c->iscustomsize = 1;
c->oldgeom = c->geom;
resize(c, c->geom, 0);
}
@ -384,6 +385,7 @@ void resizewin(const Arg *arg) {
break;
}
c->iscustomsize = 1;
c->oldgeom = c->geom;
resize(c, c->geom, 0);
}
@ -533,7 +535,7 @@ void smartmovewin(const Arg *arg) {
c->oldgeom = (struct wlr_box){
.x = nx, .y = ny, .width = c->geom.width, .height = c->geom.height};
c->iscustomsize = 1;
resize(c, c->oldgeom, 1);
}
@ -602,7 +604,7 @@ void smartresizewin(const Arg *arg) {
c->oldgeom = (struct wlr_box){
.x = c->geom.x, .y = c->geom.y, .width = nw, .height = nh};
c->iscustomsize = 1;
resize(c, c->oldgeom, 1);
}
@ -616,7 +618,7 @@ void centerwin(const Arg *arg) {
setfloating(c, true);
c->oldgeom = setclient_coordinate_center(c, c->geom, 0, 0);
c->iscustomsize = 1;
resize(c, c->oldgeom, 1);
}

View file

@ -301,6 +301,7 @@ struct Client {
const char *animation_type_open;
const char *animation_type_close;
int is_in_scratchpad;
int iscustomsize;
int is_scratchpad_show;
int isglobal;
int isnoborder;
@ -326,7 +327,6 @@ struct Client {
float focused_opacity;
float unfocused_opacity;
char oldmonname[128];
int scratchpad_width, scratchpad_height;
int noblur;
};
@ -900,17 +900,16 @@ void show_scratchpad(Client *c) {
/* return if fullscreen */
if (!c->isfloating) {
setfloating(c, 1);
c->geom.width = c->scratchpad_width ? c->scratchpad_width
: c->oldgeom.width
c->geom.width = c->iscustomsize
? c->oldgeom.width
: c->mon->w.width * scratchpad_width_ratio;
c->geom.height = c->scratchpad_height ? c->scratchpad_height
: c->oldgeom.height
c->geom.height = c->iscustomsize
? c->oldgeom.height
: c->mon->w.height * scratchpad_height_ratio;
// 重新计算居中的坐标
c->oldgeom = c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c, c->geom, 0, 0);
c->iscustomsize = 1;
resize(c, c->geom, 0);
}
@ -1078,8 +1077,6 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
APPLY_INT_PROP(c, r, ignore_minimize);
APPLY_INT_PROP(c, r, isnosizehint);
APPLY_INT_PROP(c, r, isunglobal);
APPLY_INT_PROP(c, r, scratchpad_width);
APPLY_INT_PROP(c, r, scratchpad_height);
APPLY_INT_PROP(c, r, noblur);
APPLY_FLOAT_PROP(c, r, scroller_proportion);
@ -1171,20 +1168,22 @@ void applyrules(Client *c) {
}
// set geometry of floating client
if (c->isfloating) {
if (r->width > 0)
c->geom.width = r->width;
if (r->height > 0)
c->geom.height = r->height;
if (r->width > 0)
c->oldgeom.width = r->width;
if (r->height > 0)
c->oldgeom.height = r->height;
if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) {
hit_rule_pos = true;
c->iscustomsize = 1;
c->oldgeom = setclient_coordinate_center(c, c->oldgeom, r->offsetx,
r->offsety);
}
if (c->isfloating) {
c->geom = c->oldgeom.width> 0 && c->oldgeom.height > 0 ? c->oldgeom : c->geom;
if (!c->isnosizehint)
client_set_size_bound(c);
if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) {
hit_rule_pos = true;
c->oldgeom = c->geom = setclient_coordinate_center(
c, c->geom, r->offsetx, r->offsety);
}
}
}
@ -3468,12 +3467,11 @@ void init_client_properties(Client *c) {
c->nofadein = 0;
c->nofadeout = 0;
c->no_force_center = 0;
c->scratchpad_width = 0;
c->scratchpad_height = 0;
c->isnoborder = 0;
c->isnosizehint = 0;
c->ignore_maximize = 0;
c->ignore_minimize = 1;
c->iscustomsize = 0;
}
void // old fix to 0.5
@ -3753,6 +3751,7 @@ void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
/* If we are currently grabbing the mouse, handle and return */
if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */
grabc->iscustomsize = 1;
grabc->oldgeom = (struct wlr_box){.x = (int)round(cursor->x) - grabcx,
.y = (int)round(cursor->y) - grabcy,
.width = grabc->geom.width,
@ -3760,6 +3759,7 @@ void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
resize(grabc, grabc->oldgeom, 1);
return;
} else if (cursor_mode == CurResize) {
grabc->iscustomsize = 1;
grabc->oldgeom =
(struct wlr_box){.x = grabc->geom.x,
.y = grabc->geom.y,