opt: optimzie var name

This commit is contained in:
DreamMaoMao 2025-09-09 11:02:47 +08:00
parent 1facac13d7
commit d64e654c2d
3 changed files with 45 additions and 42 deletions

View file

@ -908,7 +908,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
c->need_output_flush = true; c->need_output_flush = true;
c->dirty = true; c->dirty = true;
// oldgeom = c->geom; // float_geom = c->geom;
bbox = (interact || c->isfloating || c->isfullscreen) ? &sgeom : &c->mon->w; bbox = (interact || c->isfloating || c->isfullscreen) ? &sgeom : &c->mon->w;
if (is_scroller_layout(c->mon) && (!c->isfloating || c == grabc)) { if (is_scroller_layout(c->mon) && (!c->isfloating || c == grabc)) {

View file

@ -344,7 +344,7 @@ void movewin(const Arg *arg) {
} }
c->iscustomsize = 1; c->iscustomsize = 1;
c->oldgeom = c->geom; c->float_geom = c->geom;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
@ -386,7 +386,7 @@ void resizewin(const Arg *arg) {
} }
c->iscustomsize = 1; c->iscustomsize = 1;
c->oldgeom = c->geom; c->float_geom = c->geom;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
@ -534,10 +534,10 @@ void smartmovewin(const Arg *arg) {
break; break;
} }
c->oldgeom = (struct wlr_box){ c->float_geom = (struct wlr_box){
.x = nx, .y = ny, .width = c->geom.width, .height = c->geom.height}; .x = nx, .y = ny, .width = c->geom.width, .height = c->geom.height};
c->iscustomsize = 1; c->iscustomsize = 1;
resize(c, c->oldgeom, 1); resize(c, c->float_geom, 1);
} }
void smartresizewin(const Arg *arg) { void smartresizewin(const Arg *arg) {
@ -603,10 +603,10 @@ void smartresizewin(const Arg *arg) {
break; break;
} }
c->oldgeom = (struct wlr_box){ c->float_geom = (struct wlr_box){
.x = c->geom.x, .y = c->geom.y, .width = nw, .height = nh}; .x = c->geom.x, .y = c->geom.y, .width = nw, .height = nh};
c->iscustomsize = 1; c->iscustomsize = 1;
resize(c, c->oldgeom, 1); resize(c, c->float_geom, 1);
} }
void centerwin(const Arg *arg) { void centerwin(const Arg *arg) {
@ -618,9 +618,9 @@ void centerwin(const Arg *arg) {
if (!c->isfloating) if (!c->isfloating)
setfloating(c, true); setfloating(c, true);
c->oldgeom = setclient_coordinate_center(c, c->geom, 0, 0); c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0);
c->iscustomsize = 1; c->iscustomsize = 1;
resize(c, c->oldgeom, 1); resize(c, c->float_geom, 1);
} }
void spawn_shell(const Arg *arg) { void spawn_shell(const Arg *arg) {
@ -953,7 +953,7 @@ void tagmon(const Arg *arg) {
target = get_tags_first_tag(c->tags); target = get_tags_first_tag(c->tags);
view(&(Arg){.ui = target}, true); view(&(Arg){.ui = target}, true);
focusclient(c, 1); focusclient(c, 1);
c->oldgeom = c->geom; c->float_geom = c->geom;
resize(c, c->geom, 1); resize(c, c->geom, 1);
} else { } else {
selmon = c->mon; selmon = c->mon;

View file

@ -249,8 +249,8 @@ typedef struct Client Client;
struct Client { struct Client {
/* Must keep these three elements in this order */ /* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */ unsigned int type; /* XDGShell or X11* */
struct wlr_box geom, pending, oldgeom, animainit_geom, overview_backup_geom, struct wlr_box geom, pending, float_geom, animainit_geom,
current; /* layout-relative, includes border */ overview_backup_geom, current; /* layout-relative, includes border */
Monitor *mon; Monitor *mon;
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_rect *border; /* top, bottom, left, right */ struct wlr_scene_rect *border; /* top, bottom, left, right */
@ -857,7 +857,7 @@ void client_change_mon(Client *c, Monitor *m) {
setmon(c, m, c->tags, true); setmon(c, m, c->tags, true);
reset_foreign_tolevel(c); reset_foreign_tolevel(c);
if (c->isfloating) { if (c->isfloating) {
c->oldgeom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0); c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
} }
} }
@ -905,13 +905,13 @@ void show_scratchpad(Client *c) {
if (!c->isfloating) { if (!c->isfloating) {
setfloating(c, 1); setfloating(c, 1);
c->geom.width = c->iscustomsize c->geom.width = c->iscustomsize
? c->oldgeom.width ? c->float_geom.width
: c->mon->w.width * scratchpad_width_ratio; : c->mon->w.width * scratchpad_width_ratio;
c->geom.height = c->iscustomsize c->geom.height = c->iscustomsize
? c->oldgeom.height ? c->float_geom.height
: c->mon->w.height * scratchpad_height_ratio; : c->mon->w.height * scratchpad_height_ratio;
// 重新计算居中的坐标 // 重新计算居中的坐标
c->oldgeom = c->geom = c->animainit_geom = c->animation.current = c->float_geom = c->geom = c->animainit_geom = c->animation.current =
setclient_coordinate_center(c, c->geom, 0, 0); setclient_coordinate_center(c, c->geom, 0, 0);
c->iscustomsize = 1; c->iscustomsize = 1;
resize(c, c->geom, 0); resize(c, c->geom, 0);
@ -943,7 +943,7 @@ void swallow(Client *c, Client *w) {
c->is_scratchpad_show = w->is_scratchpad_show; c->is_scratchpad_show = w->is_scratchpad_show;
c->tags = w->tags; c->tags = w->tags;
c->geom = w->geom; c->geom = w->geom;
c->oldgeom = w->oldgeom; c->float_geom = w->float_geom;
c->scroller_proportion = w->scroller_proportion; c->scroller_proportion = w->scroller_proportion;
wl_list_insert(&w->link, &c->link); wl_list_insert(&w->link, &c->link);
wl_list_insert(&w->flink, &c->flink); wl_list_insert(&w->flink, &c->flink);
@ -1175,19 +1175,20 @@ void applyrules(Client *c) {
// set geometry of floating client // set geometry of floating client
if (r->width > 0) if (r->width > 0)
c->oldgeom.width = r->width; c->float_geom.width = r->width;
if (r->height > 0) if (r->height > 0)
c->oldgeom.height = r->height; c->float_geom.height = r->height;
if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) { if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) {
hit_rule_pos = true; hit_rule_pos = true;
c->iscustomsize = 1; c->iscustomsize = 1;
c->oldgeom = setclient_coordinate_center(c, c->oldgeom, r->offsetx, c->float_geom = setclient_coordinate_center(c, c->float_geom,
r->offsety); r->offsetx, r->offsety);
} }
if (c->isfloating) { if (c->isfloating) {
c->geom = c->oldgeom.width > 0 && c->oldgeom.height > 0 ? c->oldgeom c->geom = c->float_geom.width > 0 && c->float_geom.height > 0
: c->geom; ? c->float_geom
: c->geom;
if (!c->isnosizehint) if (!c->isnosizehint)
client_set_size_bound(c); client_set_size_bound(c);
} }
@ -1197,7 +1198,7 @@ void applyrules(Client *c) {
// the hit size // the hit size
if (!hit_rule_pos && if (!hit_rule_pos &&
(!client_is_x11(c) || !client_should_ignore_focus(c))) { (!client_is_x11(c) || !client_should_ignore_focus(c))) {
c->oldgeom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0); c->float_geom = c->geom = setclient_coordinate_center(c, c->geom, 0, 0);
} }
/*-----------------------apply rule action-------------------------*/ /*-----------------------apply rule action-------------------------*/
@ -1516,7 +1517,7 @@ void apply_window_snap(Client *c) {
c->geom.y = c->geom.y + snap_down; c->geom.y = c->geom.y + snap_down;
} }
c->oldgeom = c->geom; c->float_geom = c->geom;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
@ -3788,20 +3789,21 @@ void motionnotify(unsigned int time, struct wlr_input_device *device, double dx,
if (cursor_mode == CurMove) { if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */ /* Move the grabbed client to the new position. */
grabc->iscustomsize = 1; grabc->iscustomsize = 1;
grabc->oldgeom = (struct wlr_box){.x = (int)round(cursor->x) - grabcx, grabc->float_geom =
.y = (int)round(cursor->y) - grabcy, (struct wlr_box){.x = (int)round(cursor->x) - grabcx,
.width = grabc->geom.width, .y = (int)round(cursor->y) - grabcy,
.height = grabc->geom.height}; .width = grabc->geom.width,
resize(grabc, grabc->oldgeom, 1); .height = grabc->geom.height};
resize(grabc, grabc->float_geom, 1);
return; return;
} else if (cursor_mode == CurResize) { } else if (cursor_mode == CurResize) {
grabc->iscustomsize = 1; grabc->iscustomsize = 1;
grabc->oldgeom = grabc->float_geom =
(struct wlr_box){.x = grabc->geom.x, (struct wlr_box){.x = grabc->geom.x,
.y = grabc->geom.y, .y = grabc->geom.y,
.width = (int)round(cursor->x) - grabc->geom.x, .width = (int)round(cursor->x) - grabc->geom.x,
.height = (int)round(cursor->y) - grabc->geom.y}; .height = (int)round(cursor->y) - grabc->geom.y};
resize(grabc, grabc->oldgeom, 1); resize(grabc, grabc->float_geom, 1);
return; return;
} }
@ -4271,19 +4273,20 @@ setfloating(Client *c, int floating) {
c->geom = backup_box; c->geom = backup_box;
// restore to the memeroy geom // restore to the memeroy geom
if (c->oldgeom.width > 0 && c->oldgeom.height > 0) { if (c->float_geom.width > 0 && c->float_geom.height > 0) {
if (c->mon && c->oldgeom.width >= c->mon->w.width - gappoh) { if (c->mon && c->float_geom.width >= c->mon->w.width - gappoh) {
c->oldgeom.width = c->mon->w.width * 0.9; c->float_geom.width = c->mon->w.width * 0.9;
window_size_outofrange = true; window_size_outofrange = true;
} }
if (c->mon && c->oldgeom.height >= c->mon->w.height - gappov) { if (c->mon && c->float_geom.height >= c->mon->w.height - gappov) {
c->oldgeom.height = c->mon->w.height * 0.9; c->float_geom.height = c->mon->w.height * 0.9;
window_size_outofrange = true; window_size_outofrange = true;
} }
if (window_size_outofrange) { if (window_size_outofrange) {
c->oldgeom = setclient_coordinate_center(c, c->oldgeom, 0, 0); c->float_geom =
setclient_coordinate_center(c, c->float_geom, 0, 0);
} }
resize(c, c->oldgeom, 0); resize(c, c->float_geom, 0);
} else { } else {
resize(c, target_box, 0); resize(c, target_box, 0);
} }
@ -4339,7 +4342,7 @@ void setmaxmizescreen(Client *c, int maxmizescreen) {
setfullscreen(c, 0); setfullscreen(c, 0);
if (c->isfloating) if (c->isfloating)
c->oldgeom = c->geom; c->float_geom = c->geom;
if (selmon->isoverview) { if (selmon->isoverview) {
Arg arg = {0}; Arg arg = {0};
toggleoverview(&arg); toggleoverview(&arg);
@ -4389,7 +4392,7 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
setmaxmizescreen(c, 0); setmaxmizescreen(c, 0);
if (c->isfloating) if (c->isfloating)
c->oldgeom = c->geom; c->float_geom = c->geom;
if (selmon->isoverview) { if (selmon->isoverview) {
Arg arg = {0}; Arg arg = {0};
toggleoverview(&arg); toggleoverview(&arg);
@ -5250,7 +5253,7 @@ void updatemons(struct wl_listener *listener, void *data) {
if (c->isfloating && c->mon == m) { if (c->isfloating && c->mon == m) {
c->geom.x += mon_pos_offsetx; c->geom.x += mon_pos_offsetx;
c->geom.y += mon_pos_offsety; c->geom.y += mon_pos_offsety;
c->oldgeom = c->geom; c->float_geom = c->geom;
resize(c, c->geom, 1); resize(c, c->geom, 1);
} }