summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--config.def.h8
-rw-r--r--patch/focusadjacenttag.c73
-rw-r--r--patch/focusadjacenttag.h6
-rw-r--r--patch/include.c4
-rw-r--r--patch/include.h4
-rw-r--r--patches.h7
7 files changed, 107 insertions, 1 deletions
diff --git a/README.md b/README.md
index 917fb23..d678005 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-10-02 - Added restartsig and emptyview patch
+2019-10-02 - Added restartsig, emptyview and focusadjacenttag patches
2019-10-01 - Added leftlayout, fullscreen, holdbar and unfloatvisible patches
@@ -101,6 +101,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [floatbordercolor](https://dwm.suckless.org/patches/float_border_color/)
- this patch allows a different border color to be chosen for floating windows
+ - [focusadjacenttag](https://dwm.suckless.org/patches/focusadjacenttag/)
+ - provides the ability to focus the tag on the immediate left or right of the currently focused tag
+ - it also allows to send the focused window either on the left or the right tag
+
- [focusonclick](https://dwm.suckless.org/patches/focusonclick/)
- this patch makes you switch focus only by mouse click and not sloppy (focus follows mouse pointer)
diff --git a/config.def.h b/config.def.h
index ce6a6ca..4459f49 100644
--- a/config.def.h
+++ b/config.def.h
@@ -398,6 +398,14 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
+ #if FOCUSADJACENTTAG_PATCH
+ { MODKEY, XK_Left, viewtoleft, {0} },
+ { MODKEY, XK_Right, viewtoright, {0} },
+ { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} },
+ { MODKEY|ShiftMask, XK_Right, tagtoright, {0} },
+ { MODKEY|ControlMask, XK_Left, tagandviewtoleft, {0} },
+ { MODKEY|ControlMask, XK_Right, tagandviewtoright, {0} },
+ #endif // FOCUSADJACENTTAG_PATCH
#if TAGALLMON_PATCH
{ MODKEY|Mod4Mask|ShiftMask, XK_comma, tagallmon, {.i = +1 } },
{ MODKEY|Mod4Mask|ShiftMask, XK_period, tagallmon, {.i = -1 } },
diff --git a/patch/focusadjacenttag.c b/patch/focusadjacenttag.c
new file mode 100644
index 0000000..5b13b54
--- /dev/null
+++ b/patch/focusadjacenttag.c
@@ -0,0 +1,73 @@
+void
+tagtoleft(const Arg *arg)
+{
+ if (selmon->sel != NULL
+ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] > 1) {
+ selmon->sel->tags >>= 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+tagtoright(const Arg *arg)
+{
+ if (selmon->sel != NULL
+ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
+ selmon->sel->tags <<= 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+viewtoleft(const Arg *arg)
+{
+ if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] > 1) {
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+viewtoright(const Arg *arg)
+{
+ if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+tagandviewtoleft(const Arg *arg)
+{
+ if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] > 1) {
+ selmon->sel->tags >>= 1;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
+ focus(selmon->sel);
+ arrange(selmon);
+ }
+}
+
+void
+tagandviewtoright(const Arg *arg)
+{
+ if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
+ selmon->sel->tags <<= 1;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
+ focus(selmon->sel);
+ arrange(selmon);
+ }
+} \ No newline at end of file
diff --git a/patch/focusadjacenttag.h b/patch/focusadjacenttag.h
new file mode 100644
index 0000000..55b1019
--- /dev/null
+++ b/patch/focusadjacenttag.h
@@ -0,0 +1,6 @@
+static void tagtoleft(const Arg *arg);
+static void tagtoright(const Arg *arg);
+static void viewtoleft(const Arg *arg);
+static void viewtoright(const Arg *arg);
+static void tagandviewtoleft(const Arg *arg);
+static void tagandviewtoright(const Arg *arg); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 920f7ff..82b151b 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -36,6 +36,10 @@
#include "ewmhtags.c"
#endif
+#if FOCUSADJACENTTAG_PATCH
+#include "focusadjacenttag.c"
+#endif
+
#if FULLSCREEN_PATCH
#include "fullscreen.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 67578c7..74b5404 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -36,6 +36,10 @@
#include "ewmhtags.h"
#endif
+#if FOCUSADJACENTTAG_PATCH
+#include "focusadjacenttag.h"
+#endif
+
#if FULLSCREEN_PATCH
#include "fullscreen.h"
#endif
diff --git a/patches.h b/patches.h
index 55c7165..c65bfe3 100644
--- a/patches.h
+++ b/patches.h
@@ -132,6 +132,13 @@
*/
#define FANCYBAR_PATCH 0
+/* This patch provides the ability to focus the tag on the immediate left or right of the
+ * currently focused tag. It also allows to send the focused window either on the left or
+ * the right tag.
+ * http://dwm.suckless.org/patches/focusadjacenttag/
+ */
+#define FOCUSADJACENTTAG_PATCH 1
+
/* Switch focus only by mouse click and not sloppy (focus follows mouse pointer).
* https://dwm.suckless.org/patches/focusonclick/
*/