summaryrefslogtreecommitdiff
path: root/patch/focusadjacenttag.c
diff options
context:
space:
mode:
authorBear <bear@bengtsson.win>2021-12-27 09:29:58 +0000
committerBear <bear@bengtsson.win>2021-12-27 09:29:58 +0000
commit69262b01ced79c2d776fab9b889926d1816a1e7a (patch)
treef304cd6fa8734e83a7772d07dc9b484781565155 /patch/focusadjacenttag.c
Added DWM
Diffstat (limited to 'patch/focusadjacenttag.c')
-rw-r--r--patch/focusadjacenttag.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/patch/focusadjacenttag.c b/patch/focusadjacenttag.c
new file mode 100644
index 0000000..1665c18
--- /dev/null
+++ b/patch/focusadjacenttag.c
@@ -0,0 +1,102 @@
+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 */
+ #if PERTAG_PATCH
+ pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] >> 1 }));
+ #else
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
+ #endif // pertagview
+ focus(NULL);
+ arrange(selmon);
+ #if BAR_EWMHTAGS_PATCH
+ updatecurrentdesktop();
+ #endif // BAR_EWMHTAGS_PATCH
+ }
+}
+
+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 */
+ #if PERTAG_PATCH
+ pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] << 1 }));
+ #else
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
+ #endif // pertagview
+ focus(NULL);
+ arrange(selmon);
+ #if BAR_EWMHTAGS_PATCH
+ updatecurrentdesktop();
+ #endif // BAR_EWMHTAGS_PATCH
+ }
+}
+
+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 */
+ #if PERTAG_PATCH
+ pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] >> 1 }));
+ #else
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
+ #endif // pertagview
+ focus(selmon->sel);
+ arrange(selmon);
+ #if BAR_EWMHTAGS_PATCH
+ updatecurrentdesktop();
+ #endif // BAR_EWMHTAGS_PATCH
+ }
+}
+
+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 */
+ #if PERTAG_PATCH
+ pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] << 1 }));
+ #else
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
+ #endif // pertagview
+ focus(selmon->sel);
+ arrange(selmon);
+ #if BAR_EWMHTAGS_PATCH
+ updatecurrentdesktop();
+ #endif // BAR_EWMHTAGS_PATCH
+ }
+}
+