Browse Source

attempt bug fix tile

master
revol-xut 1 year ago
parent
commit
8702f10f2b
2 changed files with 40 additions and 26 deletions
  1. +2
    -1
      config.def.h
  2. +38
    -25
      layouts.c

+ 2
- 1
config.def.h View File

@ -109,7 +109,7 @@ static const char *termcmd[] = { TERMINAL, NULL };
/*
* Xresources preferences to load at startup
*/
ResourcePref resources[] = {
{ "dwm.color0", STRING, &normbordercolor },
{ "dwm.color8", STRING, &selbordercolor },
@ -131,6 +131,7 @@ ResourcePref resources[] = {
{ "swallowfloating", INTEGER, &swallowfloating },
{ "smartgaps", INTEGER, &smartgaps },
};
*/
#include <X11/XF86keysym.h>
#include "shiftview.c"


+ 38
- 25
layouts.c View File

@ -403,29 +403,42 @@ static void spiral(Monitor *m) {
/*
* Default tile layout + gaps
*/
static void tile(Monitor *m) {
unsigned int i, n, h, mw, my, ty;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww;
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx, m->wy + my, mw - (2 * c->bw), h - (2 * c->bw), 0);
if (my + HEIGHT(c) < m->wh)
my += HEIGHT(c);
} else {
h = (m->wh - ty) / (n - i);
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2 * c->bw), h - (2 * c->bw), 0);
if (ty + HEIGHT(c) < m->wh)
ty += HEIGHT(c);
}
static void tile(Monitor *m)
{
unsigned int i, n;
int mx = 0, my = 0, mh = 0, mw = 0;
int sx = 0, sy = 0, sh = 0, sw = 0;
float mfacts, sfacts;
int mrest, srest;
Client *c;
int oh, ov, ih, iv;
getgaps(m, &oh, &ov, &ih, &iv, &n);
if (n == 0)
return;
sx = mx = m->wx + ov;
sy = my = m->wy + oh;
mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
sw = mw = m->ww - 2*ov;
if (m->nmaster && n > m->nmaster) {
sw = (mw - iv) * (1 - m->mfact);
mw = (mw - iv) * m->mfact;
sx = mx + mw + iv;
}
getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest);
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0);
my += HEIGHT(c) + ih;
} else {
resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0);
sy += HEIGHT(c) + ih;
}
}

Loading…
Cancel
Save