summaryrefslogtreecommitdiff
path: root/patch/push_no_master.c
blob: 2d78cf4fb273c1d9b32e933d9023711e0d7d9a79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Client *
prevt(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, *c;

	if (!sel || sel->isfloating)
		return;
	if ((c = prevt(sel)) && c != nexttiled(selmon->clients)) {
		detach(sel);
		sel->next = c;
		for (c = selmon->clients; c->next != sel->next; c = c->next);
		c->next = sel;
	}
	focus(sel);
	arrange(selmon);
}

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

	if (!sel || sel->isfloating || sel == nexttiled(selmon->clients))
		return;
	if ((c = nexttiled(sel->next))) {
		detach(sel);
		sel->next = c->next;
		c->next = sel;
	}
	focus(sel);
	arrange(selmon);
}