push.c
author Stiletto <blasux@blasux.ru>
Wed, 02 Apr 2014 20:49:20 +0400
branchstil
changeset 1541 16039d3a6270
parent 1532 4a1df4ff7ca3
permissions -rw-r--r--
Fix broken merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1532
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     1
static Client *
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     2
prevtiled(Client *c) {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     3
	Client *p, *r;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     4
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     5
	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     6
		if(!p->isfloating && ISVISIBLE(p))
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     7
			r = p;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     8
	return r;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
     9
}
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    10
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    11
static void
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    12
pushup(const Arg *arg) {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    13
	Client *sel = selmon->sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    14
	Client *c;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    15
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    16
	if(!sel || sel->isfloating)
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    17
		return;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    18
	if((c = prevtiled(sel))) {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    19
		/* attach before c */
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    20
		detach(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    21
		sel->next = c;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    22
		if(selmon->clients == c)
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    23
			selmon->clients = sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    24
		else {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    25
			for(c = selmon->clients; c->next != sel->next; c = c->next);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    26
			c->next = sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    27
		}
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    28
	} else {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    29
		/* move to the end */
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    30
		for(c = sel; c->next; c = c->next);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    31
		detach(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    32
		sel->next = NULL;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    33
		c->next = sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    34
	}
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    35
	focus(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    36
	arrange(selmon);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    37
}
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    38
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    39
static void
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    40
pushdown(const Arg *arg) {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    41
	Client *sel = selmon->sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    42
	Client *c;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    43
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    44
	if(!sel || sel->isfloating)
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    45
		return;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    46
	if((c = nexttiled(sel->next))) {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    47
		/* attach after c */
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    48
		detach(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    49
		sel->next = c->next;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    50
		c->next = sel;
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    51
	} else {
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    52
		/* move to the front */
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    53
		detach(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    54
		attach(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    55
	}
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    56
	focus(sel);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    57
	arrange(selmon);
4a1df4ff7ca3 pushup and pushdown provide a way to move clients inside the clients list
Zetoke <zetoke@ya.ru>
parents:
diff changeset
    58
}