dwm-flexipatch/patch/push.c

71 lines
1.2 KiB
C
Raw Normal View History

2019-09-14 22:22:24 +00:00
static Client *
2019-09-13 22:36:18 +00:00
nextc(Client *c, float f)
{
if (!f)
return nexttiled(c);
for (; c && !ISVISIBLE(c); c = c->next);
return c;
}
static Client *
prevc(Client *c, float f)
{
Client *p, *r;
for (p = selmon->clients, r = NULL; c && p && p != c; p = p->next)
if ((f || !p->isfloating) && ISVISIBLE(p))
r = p;
return r;
}
static void
pushup(const Arg *arg)
{
Client *sel = selmon->sel;
Client *c;
if (!sel || (sel->isfloating && !arg->f))
return;
if ((c = prevc(sel, arg->f))) {
/* attach before c */
detach(sel);
sel->next = c;
if (selmon->clients == c)
selmon->clients = sel;
else {
2019-09-14 22:43:35 +00:00
for (c = selmon->clients; c->next != sel->next; c = c->next);
2019-09-13 22:36:18 +00:00
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);
}
static void
pushdown(const Arg *arg)
{
Client *sel = selmon->sel;
Client *c;
if (!sel || (sel->isfloating && !arg->f))
return;
if ((c = nextc(sel->next, arg->f))) {
/* attach after c */
detach(sel);
sel->next = c->next;
c->next = sel;
} else {
/* move to the front */
detach(sel);
attach(sel);
}
focus(sel);
arrange(selmon);
}