Merge pull request #159 from DreamMaoMao/fix-smartgap

fix: smartgap shouldn't affect by non-tiling window
This commit is contained in:
DreamMaoMao 2025-07-07 14:04:01 +08:00 committed by GitHub
commit 296b375e2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 64 additions and 54 deletions

View file

@ -6,10 +6,10 @@ void fibonacci(Monitor *mon, int s) {
unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0;
unsigned int cur_gappov = enablegaps ? mon->gappov : 0;
cur_gappih = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov;
// Count visible clients
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c))
n++;
@ -28,7 +28,8 @@ void fibonacci(Monitor *mon, int s) {
if (!VISIBLEON(c, mon) || !ISTILED(c))
continue;
c->bw = mon->visible_clients == 1 && no_border_when_single && smartgaps
c->bw = mon->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if ((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) {
@ -146,10 +147,10 @@ void grid(Monitor *m) {
if (n == 1) {
wl_list_for_each(c, &clients, link) {
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) ||
ISTILED(c))) {
@ -170,10 +171,10 @@ void grid(Monitor *m) {
ch = (m->w.height - 2 * overviewgappo) * 0.65;
i = 0;
wl_list_for_each(c, &clients, link) {
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) ||
ISTILED(c))) {
@ -218,9 +219,10 @@ void grid(Monitor *m) {
// 调整每个客户端的位置和大小
i = 0;
wl_list_for_each(c, &clients, link) {
c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
cx = m->w.x + (i % cols) * (cw + overviewgappi);
@ -247,10 +249,10 @@ void deck(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
if (n == 0)
@ -310,9 +312,9 @@ void scroller(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
unsigned int max_client_width =
m->w.width - 2 * scroller_structs - cur_gappih;
@ -447,10 +449,10 @@ void tile(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
if (n > selmon->pertag->nmasters[selmon->pertag->curtag])
mw = selmon->pertag->nmasters[selmon->pertag->curtag]

View file

@ -6,10 +6,10 @@ void vertical_fibonacci(Monitor *mon, int s) {
unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0;
unsigned int cur_gappov = enablegaps ? mon->gappov : 0;
cur_gappih = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov;
// Count visible clients
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c))
n++;
@ -28,7 +28,8 @@ void vertical_fibonacci(Monitor *mon, int s) {
if (!VISIBLEON(c, mon) || !ISTILED(c))
continue;
c->bw = mon->visible_clients == 1 && no_border_when_single && smartgaps
c->bw = mon->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if ((i % 2 && nw / 2 > 2 * c->bw) || (!(i % 2) && nh / 2 > 2 * c->bw)) {
@ -144,10 +145,10 @@ void vertical_grid(Monitor *m) {
if (n == 1) {
wl_list_for_each(c, &clients, link) {
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) ||
ISTILED(c))) {
@ -168,10 +169,10 @@ void vertical_grid(Monitor *m) {
cw = (m->w.width - 2 * overviewgappo) * 0.65;
i = 0;
wl_list_for_each(c, &clients, link) {
c->bw =
m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) ||
ISTILED(c))) {
@ -213,9 +214,10 @@ void vertical_grid(Monitor *m) {
i = 0;
wl_list_for_each(c, &clients, link) {
c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) {
cx = m->w.x + (i / rows) * (cw + overviewgappi);
@ -242,10 +244,10 @@ void vertical_deck(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++;
if (n == 0)
@ -299,9 +301,9 @@ void vertical_scroller(Monitor *m) {
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
unsigned int max_client_height =
m->w.height - 2 * scroller_structs - cur_gappiv;
@ -432,10 +434,10 @@ void vertical_tile(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
if (n > selmon->pertag->nmasters[selmon->pertag->curtag])
mh = selmon->pertag->nmasters[selmon->pertag->curtag]

View file

@ -413,6 +413,7 @@ struct Monitor {
int gamma_lut_changed;
int asleep;
unsigned int visible_clients;
unsigned int visible_tiling_clients;
struct wlr_scene_optimized_blur *blur;
char last_surface_ws_name[256];
};
@ -1472,6 +1473,7 @@ arrange(Monitor *m, bool want_animation) {
return;
m->visible_clients = 0;
m->visible_tiling_clients = 0;
wl_list_for_each(c, &clients, link) {
if (c->iskilling)
continue;
@ -1489,6 +1491,10 @@ arrange(Monitor *m, bool want_animation) {
m->visible_clients++;
}
if (ISTILED(c)) {
m->visible_tiling_clients++;
}
if (!c->is_clip_to_hide || !ISTILED(c) ||
!is_scroller_layout(c->mon)) {
c->is_clip_to_hide = false;