1. mt3
  2. dwm

Source

dwm / functions.c

The default branch has multiple heads

void
tagandview(const Arg *arg) {
	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
		return;
	selmon->seltags ^= 1; /* toggle sel tagset */
	if(selmon->sel && arg->ui & TAGMASK) 
		selmon->tagset[selmon->seltags] = selmon->sel->tags = arg->ui & TAGMASK;
	if(selmon->showbar != selmon->showbars[selmon->curtag])
		togglebar(NULL);
	arrange(selmon);
}

void 
tagnextmon(const Arg *arg) {
    Monitor *m;
    Client *c = selmon->sel;
	if(!selmon->sel || !mons->next)
		return;
    if(!(m = selmon->next))
			m = mons;
    sendmon(c, m);
	if(c && arg->ui & TAGMASK) {
		c->tags = arg->ui & TAGMASK;
		arrange(m);
    }
}

void
viewmon(const Arg *arg) {
    Monitor *m; 
    if (!mons->next)
        return;
    if(!(m = selmon->next))
        m = mons;
	m->seltags ^= 1; /* toggle sel tagset */
    if(arg->ui & TAGMASK)
        m->tagset[m->seltags] = arg->ui & TAGMASK;
    unfocus(selmon->sel);
    selmon=m;
    focus(NULL);
    arrange(m);
}
void
tagviewnextmon(const Arg *arg) {
    Monitor *m; 
    Client *c = selmon->sel;
    if (!mons->next)
        return;
    if(!(m = selmon->next))
        m = mons;
    sendmon(c, m);
	if(c && arg->ui & TAGMASK) {
		c->tags = arg->ui & TAGMASK;
    }
	m->seltags ^= 1; /* toggle sel tagset */
    if(arg->ui & TAGMASK)
        m->tagset[m->seltags] = arg->ui & TAGMASK;
    unfocus(selmon->sel);
    selmon=m;
    focus(c);
    arrange(m);
}
Client *
prevtiled(Client *c) {
	Client *p, *r;

	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
		if(!p->isfloating && ISVISIBLE(p))
			r = p;
	return r;
}

void
pushup(const Arg *arg) {
	Client *sel = selmon->sel;
	Client *c;

	if(!sel || sel->isfloating)
		return;
	if((c = prevtiled(sel))) {
		/* attach before c */
		detach(sel);
		sel->next = c;
		if(selmon->clients == c)
			selmon->clients = sel;
		else {
			for(c = selmon->clients; c->next != sel->next; c = c->next);
			c->next = sel;
		}
	} else {
		/* move to the end */
		for(c = sel; c->next; c = c->next);
		detach(sel);
		sel->next = NULL;
		c->next = sel;
	}
	focus(sel);
	arrange(selmon);
}

void
pushdown(const Arg *arg) {
	Client *sel = selmon->sel;
	Client *c;

	if(!sel || sel->isfloating)
		return;
	if((c = nexttiled(sel->next))) {
		detach(sel);
		sel->next = c->next;
		c->next = sel;
	} else {
		detach(sel);
		attach(sel);
	}
	focus(sel);
	arrange(selmon);
}
void
viewall(const Arg *arg) {
	unsigned int i;
    Monitor *m; 

    if (!mons->next) {
        return;
    }

    for(m=mons; m; m=m->next) {
        if((arg->ui & TAGMASK) != m->tagset[m->seltags]) {
            m->seltags ^= 1; 
            if(arg->ui & TAGMASK) {
                m->tagset[m->seltags] = arg->ui & TAGMASK;
                m->prevtag = m->curtag;
                if(arg->ui == ~0)
                    m->curtag = 0;
                else {
                    for (i=0; !(arg->ui & 1 << i); i++);
                    m->curtag = i + 1;
                }
            } else {
                m->prevtag= m->curtag ^ m->prevtag;
                m->curtag^= m->prevtag;
                m->prevtag= m->curtag ^ m->prevtag;
            }
            m->lt[m->sellt]= m->lts[m->curtag];
            m->mfact = m->mfacts[m->curtag];
            if(m->showbar != m->showbars[m->curtag])
                togglebar(NULL);
            arrange(m);
        }
    }
}
void
incnmaster(const Arg *arg) {
    int cur;
	if(!arg || !selmon->lt[selmon->sellt]->arrange )
		return;
	cur = selmon->nmasters[selmon->curtag] + arg->i;
	if(cur < 1)
        return;
    selmon->nmaster = selmon->nmasters[selmon->curtag] = cur;
	arrange(selmon);
}
static void
ntile(Monitor *m) {
	int x, y, h, w, mw, nm;
	unsigned int i, n;
	Client *c;

	/* override layout symbol */
    //snprintf(selmon->ltsymbol, sizeof selmon->ltsymbol, "%d]=", nmasters[m->num]);
	snprintf(m->ltsymbol, sizeof m->ltsymbol, "%d]=", m->nmasters[m->curtag]);
	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	c = nexttiled(m->clients);
    nm = m->nmasters[m->curtag]; 
	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);
	}
}