summaryrefslogtreecommitdiff
path: root/patch/swapfocus.c
diff options
context:
space:
mode:
Diffstat (limited to 'patch/swapfocus.c')
-rw-r--r--patch/swapfocus.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/patch/swapfocus.c b/patch/swapfocus.c
new file mode 100644
index 0000000..ec85c2e
--- /dev/null
+++ b/patch/swapfocus.c
@@ -0,0 +1,22 @@
+void
+swapfocus(const Arg *arg)
+{
+ if (!selmon->sel)
+ return;
+ if (selmon->pertag->prevclient[selmon->pertag->curtag] != NULL
+ && ISVISIBLE(selmon->pertag->prevclient[selmon->pertag->curtag])) {
+ focus(selmon->pertag->prevclient[selmon->pertag->curtag]);
+ restack(selmon->pertag->prevclient[selmon->pertag->curtag]->mon);
+ }
+ else {
+ Client *c = NULL;
+ for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
+ if (!c)
+ for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
+ if (c) {
+ focus(c);
+ restack(selmon);
+ }
+ }
+}
+