2020-03-23 11:15:50 +00:00
|
|
|
void
|
|
|
|
focusstack(const Arg *arg)
|
|
|
|
{
|
|
|
|
int i = stackpos(arg);
|
|
|
|
Client *c, *p;
|
|
|
|
|
|
|
|
if (i < 0)
|
|
|
|
return;
|
|
|
|
|
2021-04-29 07:05:32 +00:00
|
|
|
#if LOSEFULLSCREEN_PATCH
|
|
|
|
if (!selmon->sel)
|
|
|
|
return;
|
|
|
|
#elif FAKEFULLSCREEN_CLIENT_PATCH
|
|
|
|
if (!selmon->sel || (selmon->sel->isfullscreen && !selmon->sel->fakefullscreen))
|
|
|
|
return;
|
|
|
|
#else
|
2020-03-23 11:15:50 +00:00
|
|
|
if (!selmon->sel || selmon->sel->isfullscreen)
|
|
|
|
return;
|
2021-03-29 17:33:05 +00:00
|
|
|
#endif // LOSEFULLSCREEN_PATCH
|
2020-03-23 11:15:50 +00:00
|
|
|
|
2021-02-17 13:37:20 +00:00
|
|
|
#if BAR_WINTITLEACTIONS_PATCH
|
|
|
|
for (p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c) || HIDDEN(c));
|
|
|
|
i -= (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), p = c, c = c->next);
|
|
|
|
#else
|
2020-03-23 11:15:50 +00:00
|
|
|
for (p = NULL, c = selmon->clients; c && (i || !ISVISIBLE(c));
|
2021-02-17 13:37:20 +00:00
|
|
|
i -= (ISVISIBLE(c) ? 1 : 0), p = c, c = c->next);
|
|
|
|
#endif // BAR_WINTITLEACTIONS_PATCH
|
2020-03-23 11:15:50 +00:00
|
|
|
focus(c ? c : p);
|
|
|
|
restack(selmon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pushstack(const Arg *arg)
|
|
|
|
{
|
|
|
|
int i = stackpos(arg);
|
|
|
|
Client *sel = selmon->sel, *c, *p;
|
|
|
|
|
|
|
|
if (i < 0)
|
|
|
|
return;
|
|
|
|
else if (i == 0) {
|
|
|
|
detach(sel);
|
|
|
|
attach(sel);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (p = NULL, c = selmon->clients; c; p = c, c = c->next)
|
2021-02-17 13:37:20 +00:00
|
|
|
#if BAR_WINTITLEACTIONS_PATCH
|
|
|
|
if (!(i -= (ISVISIBLE(c) && !HIDDEN(c) && c != sel)))
|
|
|
|
#else
|
2020-03-23 11:15:50 +00:00
|
|
|
if (!(i -= (ISVISIBLE(c) && c != sel)))
|
2021-02-17 13:37:20 +00:00
|
|
|
#endif // BAR_WINTITLEACTIONS_PATCH
|
2020-03-23 11:15:50 +00:00
|
|
|
break;
|
|
|
|
c = c ? c : p;
|
|
|
|
detach(sel);
|
|
|
|
sel->next = c->next;
|
|
|
|
c->next = sel;
|
|
|
|
}
|
|
|
|
arrange(selmon);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
stackpos(const Arg *arg)
|
|
|
|
{
|
|
|
|
int n, i;
|
|
|
|
Client *c, *l;
|
|
|
|
|
|
|
|
if (!selmon->clients)
|
|
|
|
return -1;
|
|
|
|
|
2021-02-17 13:37:20 +00:00
|
|
|
#if BAR_WINTITLEACTIONS_PATCH
|
|
|
|
if (arg->i == PREVSEL) {
|
|
|
|
for (l = selmon->stack; l && (!ISVISIBLE(l) || HIDDEN(l) || l == selmon->sel); l = l->snext);
|
|
|
|
if (!l)
|
|
|
|
return -1;
|
|
|
|
for (i = 0, c = selmon->clients; c != l; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
else if (ISINC(arg->i)) {
|
|
|
|
if (!selmon->sel)
|
|
|
|
return -1;
|
|
|
|
for (i = 0, c = selmon->clients; c != selmon->sel; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
|
|
|
|
for (n = i; c; n += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
|
|
|
|
return MOD(i + GETINC(arg->i), n);
|
|
|
|
}
|
|
|
|
else if (arg->i < 0) {
|
|
|
|
for (i = 0, c = selmon->clients; c; i += (ISVISIBLE(c) && !HIDDEN(c) ? 1 : 0), c = c->next);
|
|
|
|
return MAX(i + arg->i, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return arg->i;
|
|
|
|
#else // !BAR_WINTITLEACTIONS_PATCH
|
2020-03-23 11:15:50 +00:00
|
|
|
if (arg->i == PREVSEL) {
|
|
|
|
for (l = selmon->stack; l && (!ISVISIBLE(l) || l == selmon->sel); l = l->snext);
|
|
|
|
if (!l)
|
|
|
|
return -1;
|
2021-02-17 13:37:20 +00:00
|
|
|
for (i = 0, c = selmon->clients; c != l; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
|
2020-03-23 11:15:50 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
else if (ISINC(arg->i)) {
|
2020-03-23 15:15:40 +00:00
|
|
|
if (!selmon->sel)
|
2020-03-23 11:15:50 +00:00
|
|
|
return -1;
|
2021-02-17 13:37:20 +00:00
|
|
|
for (i = 0, c = selmon->clients; c != selmon->sel; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
|
|
|
|
for (n = i; c; n += (ISVISIBLE(c) ? 1 : 0), c = c->next);
|
2020-03-23 11:15:50 +00:00
|
|
|
return MOD(i + GETINC(arg->i), n);
|
|
|
|
}
|
|
|
|
else if (arg->i < 0) {
|
2021-02-17 13:37:20 +00:00
|
|
|
for (i = 0, c = selmon->clients; c; i += (ISVISIBLE(c) ? 1 : 0), c = c->next);
|
2020-03-23 11:15:50 +00:00
|
|
|
return MAX(i + arg->i, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return arg->i;
|
2021-02-17 13:37:20 +00:00
|
|
|
#endif // BAR_WINTITLEACTIONS_PATCH
|
2020-03-23 15:15:40 +00:00
|
|
|
}
|
2021-06-14 05:16:17 +00:00
|
|
|
|