opt: optimize grid layout gap

This commit is contained in:
DreamMaoMao 2025-10-15 16:23:46 +08:00
parent 3837e8e3da
commit 86c91fc53a
2 changed files with 16 additions and 16 deletions

View file

@ -34,8 +34,8 @@ void grid(Monitor *m) {
ch = (m->w.height - 2 * target_gappo) * single_height_ratio; ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
c->geom.x = m->w.x + (m->w.width - cw) / 2; c->geom.x = m->w.x + (m->w.width - cw) / 2;
c->geom.y = m->w.y + (m->w.height - ch) / 2; c->geom.y = m->w.y + (m->w.height - ch) / 2;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
return; return;
} }
@ -60,14 +60,14 @@ void grid(Monitor *m) {
if (i == 0) { if (i == 0) {
c->geom.x = m->w.x + target_gappo; c->geom.x = m->w.x + target_gappo;
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo; c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} else if (i == 1) { } else if (i == 1) {
c->geom.x = m->w.x + cw + target_gappo + target_gappi; c->geom.x = m->w.x + cw + target_gappo + target_gappi;
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo; c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
i++; i++;
@ -114,8 +114,8 @@ void grid(Monitor *m) {
} }
c->geom.x = cx + target_gappo; c->geom.x = cx + target_gappo;
c->geom.y = cy + target_gappo; c->geom.y = cy + target_gappo;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
i++; i++;
} }

View file

@ -316,8 +316,8 @@ void vertical_grid(Monitor *m) {
cw = (m->w.width - 2 * target_gappo) * single_width_ratio; cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
c->geom.x = m->w.x + (m->w.width - cw) / 2; c->geom.x = m->w.x + (m->w.width - cw) / 2;
c->geom.y = m->w.y + (m->w.height - ch) / 2; c->geom.y = m->w.y + (m->w.height - ch) / 2;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
return; return;
} }
@ -343,14 +343,14 @@ void vertical_grid(Monitor *m) {
if (i == 0) { if (i == 0) {
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo; c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
c->geom.y = m->w.y + target_gappo; c->geom.y = m->w.y + target_gappo;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} else if (i == 1) { } else if (i == 1) {
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo; c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
c->geom.y = m->w.y + ch + target_gappo + target_gappi; c->geom.y = m->w.y + ch + target_gappo + target_gappi;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
i++; i++;
@ -393,8 +393,8 @@ void vertical_grid(Monitor *m) {
} }
c->geom.x = cx + target_gappo; c->geom.x = cx + target_gappo;
c->geom.y = cy + target_gappo; c->geom.y = cy + target_gappo;
c->geom.width = cw - 2 * c->bw; c->geom.width = cw;
c->geom.height = ch - 2 * c->bw; c->geom.height = ch;
resize(c, c->geom, 0); resize(c, c->geom, 0);
i++; i++;
} }