From 55592623f585246b106bf5c4f075122d07ec7070 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 20 Feb 2022 13:24:52 +0100 Subject: [PATCH] focusadjacenttags + scratchpad compatibility issue ref. #236 --- patch/focusadjacenttag.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/patch/focusadjacenttag.c b/patch/focusadjacenttag.c index b311b74..67dd768 100644 --- a/patch/focusadjacenttag.c +++ b/patch/focusadjacenttag.c @@ -1,8 +1,9 @@ void tagtoleft(const Arg *arg) { + unsigned int MASK = (1 << NUMTAGS) - 1; if (selmon->sel != NULL - && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 && selmon->tagset[selmon->seltags] > 1) { selmon->sel->tags >>= 1; focus(NULL); @@ -13,9 +14,10 @@ tagtoleft(const Arg *arg) void tagtoright(const Arg *arg) { + unsigned int MASK = (1 << NUMTAGS) - 1; if (selmon->sel != NULL - && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 - && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + && __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 + && selmon->tagset[selmon->seltags] & (MASK >> 1)) { selmon->sel->tags <<= 1; focus(NULL); arrange(selmon); @@ -25,7 +27,8 @@ tagtoright(const Arg *arg) void viewtoleft(const Arg *arg) { - if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + unsigned int MASK = (1 << NUMTAGS) - 1; + if (__builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 && selmon->tagset[selmon->seltags] > 1) { view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 })); } @@ -34,8 +37,9 @@ viewtoleft(const Arg *arg) void viewtoright(const Arg *arg) { - if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 - && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + unsigned int MASK = (1 << NUMTAGS) - 1; + if (__builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 + && selmon->tagset[selmon->seltags] & (MASK >> 1)) { view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 })); } } @@ -43,8 +47,9 @@ viewtoright(const Arg *arg) void tagandviewtoleft(const Arg *arg) { + unsigned int MASK = (1 << NUMTAGS) - 1; if (selmon->sel != NULL - && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 && selmon->tagset[selmon->seltags] > 1) { selmon->sel->tags >>= 1; view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 })); @@ -54,9 +59,10 @@ tagandviewtoleft(const Arg *arg) void tagandviewtoright(const Arg *arg) { + unsigned int MASK = (1 << NUMTAGS) - 1; if (selmon->sel != NULL - && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 - && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + && __builtin_popcount(selmon->tagset[selmon->seltags] & MASK) == 1 + && selmon->tagset[selmon->seltags] & (MASK >> 1)) { selmon->sel->tags <<= 1; view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 })); }