mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-06 13:29:53 -05:00
fix: loss gap in some window when use fibonacci layout
This commit is contained in:
parent
6615c330db
commit
075f4fe6d4
1 changed files with 100 additions and 70 deletions
170
src/maomao.c
170
src/maomao.c
|
|
@ -6002,89 +6002,119 @@ void overview(Monitor *m, unsigned int gappo, unsigned int gappi) {
|
||||||
void fibonacci(Monitor *mon, int s) {
|
void fibonacci(Monitor *mon, int s) {
|
||||||
unsigned int i = 0, n = 0, nx, ny, nw, nh;
|
unsigned int i = 0, n = 0, nx, ny, nw, nh;
|
||||||
Client *c;
|
Client *c;
|
||||||
unsigned int cur_gappih = enablegaps? mon->gappih : 0;
|
unsigned int cur_gappih = enablegaps ? mon->gappih : 0;
|
||||||
unsigned int cur_gappiv = enablegaps? mon->gappiv : 0;
|
unsigned int cur_gappiv = enablegaps ? mon->gappiv : 0;
|
||||||
unsigned int cur_gappoh = enablegaps? mon->gappoh : 0;
|
unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0;
|
||||||
unsigned int cur_gappov = enablegaps? mon->gappov : 0;
|
unsigned int cur_gappov = enablegaps ? mon->gappov : 0;
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && !c->isfloating &&
|
// Count visible clients
|
||||||
!c->iskilling && !c->isfullscreen &&
|
wl_list_for_each(c, &clients, link)
|
||||||
!c->ismaxmizescreen &&
|
if (VISIBLEON(c, mon) && !c->isfloating && !c->iskilling &&
|
||||||
!c->animation.tagouting) n++;
|
!c->isfullscreen && !c->ismaxmizescreen && !c->animation.tagouting)
|
||||||
|
n++;
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Initial dimensions including outer gaps
|
||||||
nx = mon->w.x + cur_gappoh;
|
nx = mon->w.x + cur_gappoh;
|
||||||
ny = mon->w.y + cur_gappov;
|
ny = mon->w.y + cur_gappov;
|
||||||
nw = mon->w.width - 2 * cur_gappoh;
|
nw = mon->w.width - 2 * cur_gappoh;
|
||||||
nh = mon->w.height - 2 * cur_gappov;
|
nh = mon->w.height - 2 * cur_gappov;
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && !c->isfloating &&
|
// First pass: calculate client geometries
|
||||||
!c->iskilling && !c->isfullscreen &&
|
wl_list_for_each(c, &clients, link) {
|
||||||
!c->ismaxmizescreen &&
|
if (!VISIBLEON(c, mon) || c->isfloating || c->iskilling ||
|
||||||
!c->animation.tagouting) {
|
c->isfullscreen || c->ismaxmizescreen || c->animation.tagouting)
|
||||||
if ((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
continue;
|
||||||
if (i < n - 1) {
|
|
||||||
if (i % 2) {
|
if ((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
||||||
if (i == 1) {
|
if (i < n - 1) {
|
||||||
nh = nh * c->mon->pertag->smfacts[selmon->pertag->curtag];
|
if (i % 2) {
|
||||||
} else
|
if (i == 1) {
|
||||||
nh /= 2;
|
nh = nh * mon->pertag->smfacts[mon->pertag->curtag];
|
||||||
} else
|
} else {
|
||||||
nw /= 2;
|
nh = (nh - cur_gappiv) / 2;
|
||||||
if ((i % 4) == 2 && !s)
|
}
|
||||||
nx += nw;
|
} else {
|
||||||
else if ((i % 4) == 3 && !s)
|
nw = (nw - cur_gappih) / 2;
|
||||||
ny += nh;
|
}
|
||||||
|
|
||||||
|
if ((i % 4) == 2 && !s)
|
||||||
|
nx += nw + cur_gappih;
|
||||||
|
else if ((i % 4) == 3 && !s)
|
||||||
|
ny += nh + cur_gappiv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((i % 4) == 0) {
|
||||||
|
if (s)
|
||||||
|
ny += nh + cur_gappiv;
|
||||||
|
else
|
||||||
|
ny -= nh + cur_gappiv;
|
||||||
|
} else if ((i % 4) == 1)
|
||||||
|
nx += nw + cur_gappih;
|
||||||
|
else if ((i % 4) == 2)
|
||||||
|
ny += nh + cur_gappiv;
|
||||||
|
else if ((i % 4) == 3) {
|
||||||
|
if (s)
|
||||||
|
nx += nw + cur_gappih;
|
||||||
|
else
|
||||||
|
nx -= nw + cur_gappih;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
if (n != 1)
|
||||||
|
nw = (mon->w.width - 2 * cur_gappoh) * mon->pertag->mfacts[mon->pertag->curtag];
|
||||||
|
ny = mon->w.y + cur_gappov;
|
||||||
|
} else if (i == 1) {
|
||||||
|
nw = mon->w.width - 2 * cur_gappoh - nw - cur_gappih;
|
||||||
|
} else if (i == 2) {
|
||||||
|
nh = mon->w.height - 2 * cur_gappov - nh - cur_gappiv;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i % 4) == 0) {
|
c->geom = (struct wlr_box){.x = nx, .y = ny, .width = nw, .height = nh};
|
||||||
if (s)
|
|
||||||
ny += nh;
|
|
||||||
else
|
|
||||||
ny -= nh;
|
|
||||||
} else if ((i % 4) == 1)
|
|
||||||
nx += nw;
|
|
||||||
else if ((i % 4) == 2)
|
|
||||||
ny += nh;
|
|
||||||
else if ((i % 4) == 3) {
|
|
||||||
if (s)
|
|
||||||
nx += nw;
|
|
||||||
else
|
|
||||||
nx -= nw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == 0) {
|
|
||||||
if (n != 1)
|
|
||||||
nw = (mon->w.width - 2 * cur_gappoh) *
|
|
||||||
mon->pertag->mfacts[mon->pertag->curtag];
|
|
||||||
ny = mon->w.y + cur_gappov;
|
|
||||||
} else if (i == 1) {
|
|
||||||
nw = mon->w.width - 2 * cur_gappoh - nw;
|
|
||||||
} else if (i == 2)
|
|
||||||
nh = mon->w.height - 2 * cur_gappov - nh;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->geom = (struct wlr_box){.x = nx, .y = ny, .width = nw, .height = nh};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int gih, giv;
|
// Second pass: apply gaps between clients
|
||||||
const Arg *dir_down = &(Arg){.i = DOWN};
|
wl_list_for_each(c, &clients, link) {
|
||||||
const Arg *dir_right = &(Arg){.i = RIGHT};
|
if (!VISIBLEON(c, mon) || c->isfloating || c->iskilling ||
|
||||||
|
c->isfullscreen || c->ismaxmizescreen || c->animation.tagouting)
|
||||||
|
continue;
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && !c->isfloating &&
|
unsigned int right_gap = 0;
|
||||||
!c->iskilling && !c->isfullscreen &&
|
unsigned int bottom_gap = 0;
|
||||||
!c->ismaxmizescreen &&
|
Client *nc;
|
||||||
!c->animation.tagouting) {
|
|
||||||
gih = find_client_by_direction(c, dir_right, false, true) ? cur_gappih : 0;
|
wl_list_for_each(nc, &clients, link) {
|
||||||
giv = find_client_by_direction(c, dir_down, false, true) ? cur_gappiv : 0;
|
if (!VISIBLEON(nc, mon) || nc->isfloating || nc->iskilling ||
|
||||||
resize(c,
|
nc->isfullscreen || nc->ismaxmizescreen || nc->animation.tagouting)
|
||||||
(struct wlr_box){.x = c->geom.x,
|
continue;
|
||||||
.y = c->geom.y,
|
|
||||||
.width = c->geom.width - gih,
|
if (c == nc) continue;
|
||||||
.height = c->geom.height - giv},
|
|
||||||
0);
|
// Check for right neighbor
|
||||||
|
if (c->geom.y == nc->geom.y &&
|
||||||
|
c->geom.x + c->geom.width == nc->geom.x) {
|
||||||
|
right_gap = cur_gappih;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for bottom neighbor
|
||||||
|
if (c->geom.x == nc->geom.x &&
|
||||||
|
c->geom.y + c->geom.height == nc->geom.y) {
|
||||||
|
bottom_gap = cur_gappiv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resize(c,
|
||||||
|
(struct wlr_box){
|
||||||
|
.x = c->geom.x,
|
||||||
|
.y = c->geom.y,
|
||||||
|
.width = c->geom.width - right_gap,
|
||||||
|
.height = c->geom.height - bottom_gap
|
||||||
|
},
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue