mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-23 21:37:53 -04:00
opt: center the last window in free space when arrange overview
This commit is contained in:
parent
dc3e6d7395
commit
d28cf7b4d2
1 changed files with 36 additions and 3 deletions
|
|
@ -175,7 +175,6 @@ void overview_scale(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_s > 0.0f) {
|
if (best_s > 0.0f) {
|
||||||
float box_w = 0, box_h = 0;
|
|
||||||
int placed_cnt = 0;
|
int placed_cnt = 0;
|
||||||
|
|
||||||
for (int k = 0; k < n; k++) {
|
for (int k = 0; k < n; k++) {
|
||||||
|
|
@ -185,9 +184,43 @@ void overview_scale(Monitor *m) {
|
||||||
try_place(placed, placed_cnt, w, h, (float)target_gappi,
|
try_place(placed, placed_cnt, w, h, (float)target_gappi,
|
||||||
max_avail_w, max_avail_h, &out, cands, feas);
|
max_avail_w, max_avail_h, &out, cands, feas);
|
||||||
placed[placed_cnt++] = out;
|
placed[placed_cnt++] = out;
|
||||||
|
}
|
||||||
|
|
||||||
float r = out.x + w;
|
if (n > 1) {
|
||||||
float b = out.y + h;
|
float grid_box_w = 0;
|
||||||
|
for (int k = 0; k < n - 1; k++) {
|
||||||
|
float r = placed[k].x + placed[k].w;
|
||||||
|
if (r > grid_box_w)
|
||||||
|
grid_box_w = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
OvPlacedRect *last = &placed[n - 1];
|
||||||
|
float max_x = grid_box_w - last->w;
|
||||||
|
|
||||||
|
if (max_x > last->x) {
|
||||||
|
for (int k = 0; k < n - 1; k++) {
|
||||||
|
OvPlacedRect p = placed[k];
|
||||||
|
if (!(last->y + last->h + target_gappi <= p.y ||
|
||||||
|
last->y >= p.y + p.h + target_gappi)) {
|
||||||
|
if (p.x > last->x) {
|
||||||
|
float limit = p.x - target_gappi - last->w;
|
||||||
|
if (limit < max_x) {
|
||||||
|
max_x = limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (max_x > last->x) {
|
||||||
|
last->x += (max_x - last->x) / 2.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float box_w = 0, box_h = 0;
|
||||||
|
for (int k = 0; k < n; k++) {
|
||||||
|
float r = placed[k].x + placed[k].w;
|
||||||
|
float b = placed[k].y + placed[k].h;
|
||||||
if (r > box_w)
|
if (r > box_w)
|
||||||
box_w = r;
|
box_w = r;
|
||||||
if (b > box_h)
|
if (b > box_h)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue