Пример #1
0
static void
bstack(Monitor *m) {
	int x, y, h, w, mh;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	if(n == 0)
		return;
	/* master */
	c = nexttiled(m->clients);
	mh = m->mfact * m->wh;
	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
	if(--n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
	w = m->ww / n;
	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
	if(w < bh)
		w = m->ww;
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
		resize(c, x, y, /* remainder */ ((i + 1 == n)
		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
		if(w != m->ww)
			x = c->x + WIDTH(c);
	}
}
Пример #2
0
static void
bstackhoriz(Monitor *m) {
	int x, y, h, w, mh;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	if(n == 0)
		return;
	/* master */
	c = nexttiled(m->clients);
	mh = m->mfact * m->wh;
	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
	if(--n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
	w = m->ww;
	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
	h /= n;
	if(h < bh)
		h = m->wh;
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
		if(h != m->wh)
			y = c->y + HEIGHT(c);
	}
}
Пример #3
0
void
grid(Monitor *m) {
	unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
		n++;

	/* grid dimensions */
	for(rows = 0; rows <= n/2; rows++)
		if(rows*rows >= n)
			break;
	cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;

	/* window geoms (cell height/width) */
	ch = m->wh / (rows ? rows : 1);
	cw = m->ww / (cols ? cols : 1);
	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
		cx = m->wx + (i / rows) * cw;
		cy = m->wy + (i % rows) * ch;
		/* adjust height/width of last row/column's windows */
		ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
		aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
		resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
		i++;
	}
}
Пример #4
0
void
book(Monitor *m) {
    int x, y, h, w, mw;
    unsigned int n, i;
    Client *c;
    for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    if(n == 0)
        return;
    /* master */
    c = nexttiled(m->clients);
    mw = m->mfact * m->ww;
    resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
    if(--n == 0)
        return;
    /* stack */
    x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw;
    y = m->wy;
    w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw;
    h = m->wh;
    if(h < bh)
        h = m->wh;
    for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
        resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
                    ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
    }
}
Пример #5
0
static void
bstack(Monitor *m) {
    int w, h, mh, mx, tx, ty, tw;
    unsigned int i, n;
    Client *c;

    for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    if(n == 0)
        return;
    if(n > m->nmaster) {
        mh = m->nmaster ? m->mfact * m->wh : 0;
        tw = m->ww / (n - m->nmaster);
        ty = m->wy + mh;
    } 
    else {
        mh = m->wh;
        tw = m->ww;
        ty = m->wy;
    }
    for(i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
        if(i < m->nmaster) {
            w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
            resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False);
            mx += WIDTH(c);
        } 
        else {
            h = m->wh - mh;
            resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), False);
            if(tw != m->ww)
                tx += WIDTH(c);
        }
    }
}
Пример #6
0
void
gaplessgrid(Monitor *m) {
	unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
	if(n == 0)
		return;

	/* grid dimensions */
	for(cols = 0; cols <= n/2; cols++)
		if(cols*cols >= n)
			break;
	if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
		cols = 2;
	rows = n/cols;

	/* window geometries */
	cw = cols ? m->ww / cols : m->ww;
	cn = 0; /* current column number */
	rn = 0; /* current row number */
	for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
		if(i/rows + 1 > cols - n%cols)
			rows = n/cols + 1;
		ch = rows ? m->wh / rows : m->wh;
		cx = m->wx + cn*cw;
		cy = m->wy + rn*ch;
		resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
		rn++;
		if(rn >= rows) {
			rn = 0;
			cn++;
		}
	}
}
Пример #7
0
static void
bstackhoriz(Monitor *m) {
	int w, mh, mx, tx, ty, th;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->cl->clients,m); c; c = nexttiled(c->next,m), n++);
	if(n == 0)
		return;
	if(n > m->nmaster) {
		mh = m->nmaster ? m->mfact * m->wh : 0;
		th = (m->wh - mh) / (n - m->nmaster);
		ty = m->wy + mh;
	} 
	else {
		th = mh = m->wh;
		ty = m->wy;
	}
	for(i = mx = 0, tx = m->wx, c = nexttiled(m->cl->clients,m); c; c = nexttiled(c->next,m), i++) {
		if(i < m->nmaster) {
			w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
			resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False);
			mx += WIDTH(c);
		} 
		else {
			resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), False);
			if(th != m->wh)
				ty += HEIGHT(c);
		}
	}
}
Пример #8
0
/* layout's mfact is buddy list width as ww % */
void
imgrid(Monitor *m) {
	unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
  int wx; /* buddy list width and grid's wx */
  int ww; /* grid's ww */
	Client *c;
  Client *bl = NULL; /* buddy list */

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
    if(strstr(c->name, wmname)) {
      bl = c;
    }
  }
	if(n == 0)
		return;

  /* buddy list */
  if(bl) {
    wx = m->mfacts[m->curtag] * m->ww;
    ww = m->ww - wx;
    resize(bl, m->wx, m->wy, wx - 2 * bl->bw, m->wh - 2 * bl->bw, False);
    if(--n == 0)
      return;
  } else {
    wx = m->wx;
    ww = m->ww;
  }

	/* grid dimensions */
	for(cols = 0; cols <= n/2; cols++)
		if(cols*cols >= n)
			break;
	if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
		cols = 2;
	rows = n/cols;

	/* window geometries */
	cw = cols ? ww / cols : ww;
	cn = 0; /* current column number */
	rn = 0; /* current row number */
	for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
    if(c == bl) {
      --i;
      continue;
    }
		if(i/rows + 1 > cols - n%cols)
			rows = n/cols + 1;
		ch = rows ? m->wh / rows : m->wh;
		cx = wx + cn*cw;
		cy = m->wy + rn*ch;
		resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
		rn++;
		if(rn >= rows) {
			rn = 0;
			cn++;
		}
	}
}
Пример #9
0
void
fibonacci(Monitor *mon, int s) {
	unsigned int i, n, nx, ny, nw, nh;
	Client *c;

	for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
	if(n == 0)
		return;
	
	nx = mon->wx;
	ny = 0;
	nw = mon->ww;
	nh = mon->wh;
	
	for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
		if((i % 2 && nh / 2 > 2 * c->bw)
		   || (!(i % 2) && nw / 2 > 2 * c->bw)) {
			if(i < n - 1) {
				if(i % 2)
					nh /= 2;
				else
					nw /= 2;
				if((i % 4) == 2 && !s)
					nx += nw;
				else if((i % 4) == 3 && !s)
					ny += nh;
			}
			if((i % 4) == 0) {
				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->ww * selmon->mfacts[selmon->curtag];
				ny = mon->wy;
			}
			else if(i == 1)
				nw = mon->ww - nw;
			i++;
		}
		resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
	}
}
Пример #10
0
void
monocle(void) {
   unsigned int n;
   Client *c;

   for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++);
   for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
      adjustborder(c, n == 1 ? 0 : borderpx);
      resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
   }
}
Пример #11
0
void
tilemovemouse(const Arg *arg) {
	/* Could EnterNotify events be used instead? */
	Client *c, *d;
	Monitor *m;
	XEvent ev;
	int x, y;
	Bool after;

	if(!(c = selmon->sel))
		return;

	if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
		sendmon(c, m);
		selmon = m;
		focus(NULL);
	}

	if(c->isfloating || !selmon->lt[selmon->sellt]->arrange){
		movemouse(NULL);
		return;
	}
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
		None, cursor[CurMove], CurrentTime) != GrabSuccess)
		return;
	do {
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
		switch (ev.type) {
		case ConfigureRequest:
		case Expose:
		case MapRequest:
			handler[ev.type](&ev);
			break;
		case MotionNotify:
			x = ev.xmotion.x;
			y = ev.xmotion.y;
			after = False;
			for(d = nexttiled(m->clients); d; d = nexttiled(d->next)){
				if(d == c)
					after = True;
				else if(INRECT(x, y, d->x, d->y, d->w+2*borderpx, d->h+2*borderpx)){
					detach(c);
					after ? insertafter(c, d) : insertbefore(c,d);
					arrange(c->mon);
					break;
				}
			}
		}
	} while(ev.type != ButtonRelease);
	XUngrabPointer(dpy, CurrentTime);
}
Пример #12
0
static void
nbstack(Monitor *m) {
	int x, y, h, w, mh, nm, nmax;
	unsigned int i, n;
	Client *c;

	/* override layout symbol */
	snprintf(m->ltsymbol, sizeof m->ltsymbol, "T%dT", LT(m)->nmaster);
	for(n = 0, c = nexttiled(cl->clients, m); c; c = nexttiled(c->next, m), n++);
	c = nexttiled(cl->clients, m);
	nmax = LT(m)->nmaster;
	nm = nmax == 1 ? 1 : MIN(n / 2, nmax);
	if(nm > n)
		nm = n;
	/* master */
	if(nm > 0) {
		mh = LT(m)->mfact * m->wh;
		w = m->ww / nm;
		if(w < bh)
			w = m->ww;
		x = m->wx;
		for(i = 0; i < nm; i++, c = nexttiled(c->next, m)) {
			resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
			       (n == nm ? m->wh : mh) - 2 * c->bw, False);
			if(w != m->ww)
				x = c->x + WIDTH(c);
		}
		n -= nm;
	} else
		mh = 0;
	if(n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = m->wy + mh;
	w = m->ww / n;
	h = m->wh - mh;
	if(w < bh)
		w = m->ww;
	for(i = 0; c; c = nexttiled(c->next, m), i++) {
		resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
		       h - 2 * c->bw, False);
		if(w != m->ww)
			x = c->x + WIDTH(c);
	}
}
Пример #13
0
static void
ntile(Monitor *m) {
	int x, y, h, w, mw, nm;
	unsigned int i, n;
	Client *c;

	initnmaster();
	/* override layout symbol */
	snprintf(m->ltsymbol, sizeof m->ltsymbol, "%d]=", nmasters[m->num]);
	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	c = nexttiled(m->clients);
	nm = m->num < MaxMon ? nmasters[m->num] : nmaster;
	if(nm > n)
		nm = n;
	/* master */
	if(nm > 0) {
		mw = m->mfact * m->ww;
		h = m->wh / nm;
		if(h < bh)
			h = m->wh;
		y = m->wy;
		for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
			resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
			       ((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
			if(h != m->wh)
				y = c->y + HEIGHT(c);
		}
		n -= nm;
	} else
		mw = 0;
	if(n == 0)
		return;
	/* tile stack */
	x = m->wx + mw;
	y = m->wy;
	w = m->ww - mw;
	h = m->wh / n;
	if(h < bh)
		h = m->wh;
	for(i = 0; c; c = nexttiled(c->next), i++) {
		resize(c, x, y, w - 2 * c->bw,
		       ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
		if(h != m->wh)
			y = c->y + HEIGHT(c);
	}
}
Пример #14
0
static void
ntile(Monitor *m) {
	int x, y, h, w, mw, nm;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	c = nexttiled(m->clients);
	nm = m->num < MaxMon ?  selmon->nmaster[selmon->curtag] : nmaster;

	if(nm > n)
		nm = n;
	/* master */
	if(nm > 0) {
		mw = m->mfact * m->ww;
		h = m->wh / nm;
		if(h < bh)
			h = m->wh;
		y = m->wy;
		for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
			resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
			       ((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
			if(h != m->wh)
				y = c->y + HEIGHT(c);
		}
		n -= nm;
	} else
		mw = 0;
	if(n == 0)
		return;
	/* tile stack */
	x = m->wx + mw;
	y = m->wy;
	w = m->ww - mw;
	h = m->wh / n;
	if(h < bh)
		h = m->wh;
	for(i = 0; c; c = nexttiled(c->next), i++) {
		resize(c, x, y, w - 2 * c->bw,
		       ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
		if(h != m->wh)
			y = c->y + HEIGHT(c);
	}
}
Пример #15
0
static void
nbstack(Monitor *m) {
	int x, y, h, w, mh, nm;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	c = nexttiled(m->clients);
	nm = m->num < MaxMon ? selmon->nmaster[selmon->curtag] : nmaster;
	if(nm > n)
		nm = n;
	/* master */
	if(nm > 0) {
		mh = m->mfact * m->wh;
		w = m->ww / nm;
		if(w < bh)
			w = m->ww;
		x = m->wx;
		for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
			resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
			       (n == nm ? m->wh : mh) - 2 * c->bw, False);
			if(w != m->ww)
				x = c->x + WIDTH(c);
		}
		n -= nm;
	} else
		mh = 0;
	if(n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = m->wy + mh;
	w = m->ww / n;
	h = m->wh - mh;
	if(w < bh)
		w = m->ww;
	for(i = 0; c; c = nexttiled(c->next), i++) {
		resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
		       h - 2 * c->bw, False);
		if(w != m->ww)
			x = c->x + WIDTH(c);
	}
}