From d3ab291944016be14002875ef8f4a318bd672c50 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 4 Jul 2022 13:34:41 +0200 Subject: [PATCH] Adding shiftboth patch ref. #270 --- config.def.h | 10 +++++++--- patch/include.c | 3 +++ patch/include.h | 3 +++ patch/shiftboth.c | 21 +++++++++++++++++++++ patch/shiftboth.h | 1 + patches.def.h | 6 ++++++ 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 patch/shiftboth.c create mode 100644 patch/shiftboth.h diff --git a/config.def.h b/config.def.h index c7ea6c3..d723ac1 100644 --- a/config.def.h +++ b/config.def.h @@ -990,11 +990,15 @@ static Key keys[] = { #if SHIFTVIEW_PATCH { MODKEY|ShiftMask, XK_Tab, shiftview, { .i = -1 } }, { MODKEY|ShiftMask, XK_backslash, shiftview, { .i = +1 } }, - #endif // SHIFTVIEW_PATCH - #if SHIFTVIEW_CLIENTS_PATCH + #endif // SHIFTVIEW_PATCH + #if SHIFTVIEW_CLIENTS_PATCH { MODKEY|Mod4Mask, XK_Tab, shiftviewclients, { .i = -1 } }, { MODKEY|Mod4Mask, XK_backslash, shiftviewclients, { .i = +1 } }, - #endif // SHIFTVIEW_CLIENTS_PATCH + #endif // SHIFTVIEW_CLIENTS_PATCH + #if SHIFTBOTH_PATCH + { MODKEY|ControlMask, XK_Left, shiftboth, { .i = -1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoleft + { MODKEY|ControlMask, XK_Right, shiftboth, { .i = +1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoright + #endif // SHIFTBOTH_PATCH #if BAR_WINTITLEACTIONS_PATCH { MODKEY|ControlMask, XK_z, showhideclient, {0} }, #endif // BAR_WINTITLEACTIONS_PATCH diff --git a/patch/include.c b/patch/include.c index 2af5433..a4130da 100644 --- a/patch/include.c +++ b/patch/include.c @@ -232,6 +232,9 @@ #if SETBORDERPX_PATCH #include "setborderpx.c" #endif +#if SHIFTBOTH_PATCH +#include "shiftboth.c" +#endif #if SHIFTTAG_PATCH #include "shifttag.c" #endif diff --git a/patch/include.h b/patch/include.h index eb6b58f..095bd70 100644 --- a/patch/include.h +++ b/patch/include.h @@ -234,6 +234,9 @@ #if SETBORDERPX_PATCH #include "setborderpx.h" #endif +#if SHIFTBOTH_PATCH +#include "shiftboth.h" +#endif #if SHIFTTAG_PATCH #include "shifttag.h" #endif diff --git a/patch/shiftboth.c b/patch/shiftboth.c new file mode 100644 index 0000000..5c7c916 --- /dev/null +++ b/patch/shiftboth.c @@ -0,0 +1,21 @@ +void +shiftboth(const Arg *arg) +{ + Arg shifted; + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + shifted.ui = selmon->tagset[selmon->seltags]; + #else + shifted.ui = selmon->tagset[selmon->seltags]; + #endif // SCRATCHPADS_PATCH + + if (arg->i > 0) /* left circular shift */ + shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (NUMTAGS - arg->i))); + else /* right circular shift */ + shifted.ui = ((shifted.ui >> -arg->i) | (shifted.ui << (NUMTAGS + arg->i))); + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + shifted.ui &= ~SPTAGMASK; + #endif // SCRATCHPADS_PATCH + + tag(&shifted); + view(&shifted); +} diff --git a/patch/shiftboth.h b/patch/shiftboth.h new file mode 100644 index 0000000..7a9b8c2 --- /dev/null +++ b/patch/shiftboth.h @@ -0,0 +1 @@ +static void shiftboth(const Arg *arg); diff --git a/patches.def.h b/patches.def.h index 83ae574..4b6719e 100644 --- a/patches.def.h +++ b/patches.def.h @@ -968,6 +968,12 @@ */ #define SETBORDERPX_PATCH 0 +/* Combines shifttag and shiftview. Basically moves the window to the next/prev tag and follows it. + * Also see the focusadjacenttag patch. + * https://dwm.suckless.org/patches/shift-tools/ + */ +#define SHIFTBOTH_PATCH 0 + /* Moves the current selected client to the adjacent tag. * Also see the focusadjacenttag patch. * https://dwm.suckless.org/patches/shift-tools/