dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

push.c (1241B)


      1 static Client *
      2 nextc(Client *c, float f)
      3 {
      4 	if (!f)
      5 		return nexttiled(c);
      6 
      7 	for (; c && !ISVISIBLE(c); c = c->next);
      8 	return c;
      9 }
     10 
     11 static Client *
     12 prevc(Client *c, float f)
     13 {
     14 	Client *p, *r;
     15 
     16 	for (p = selmon->clients, r = NULL; c && p && p != c; p = p->next)
     17 		if ((f || !p->isfloating) && ISVISIBLE(p))
     18 			r = p;
     19 	return r;
     20 }
     21 
     22 static void
     23 pushup(const Arg *arg)
     24 {
     25 	Client *sel = selmon->sel;
     26 	Client *c;
     27 
     28 	if (!sel || (sel->isfloating && !arg->f))
     29 		return;
     30 	if ((c = prevc(sel, arg->f))) {
     31 		/* attach before c */
     32 		detach(sel);
     33 		sel->next = c;
     34 		if (selmon->clients == c)
     35 			selmon->clients = sel;
     36 		else {
     37 			for (c = selmon->clients; c->next != sel->next; c = c->next);
     38 			c->next = sel;
     39 		}
     40 	} else {
     41 		/* move to the end */
     42 		for (c = sel; c->next; c = c->next);
     43 		if (sel != c) {
     44 			detach(sel);
     45 			sel->next = NULL;
     46 			c->next = sel;
     47 		}
     48 	}
     49 	focus(sel);
     50 	arrange(selmon);
     51 }
     52 
     53 static void
     54 pushdown(const Arg *arg)
     55 {
     56 	Client *sel = selmon->sel;
     57 	Client *c;
     58 
     59 	if (!sel || (sel->isfloating && !arg->f))
     60 		return;
     61 	if ((c = nextc(sel->next, arg->f))) {
     62 		/* attach after c */
     63 		detach(sel);
     64 		sel->next = c->next;
     65 		c->next = sel;
     66 	} else {
     67 		/* move to the front */
     68 		detach(sel);
     69 		attach(sel);
     70 	}
     71 	focus(sel);
     72 	arrange(selmon);
     73 }
     74