viewto{left,right} - dwm - dynamic window manager
 (HTM) git clone https://git.parazyd.org/dwm
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e8a3ec4547d8eccc3cad32a863d3d0df7c0a2cbc
 (DIR) parent 8f6b3c299e84a2682264118ddd01b18ffb538f06
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Wed, 10 May 2023 11:58:22 +0200
       
       viewto{left,right}
       
       Diffstat:
         M config.def.h                        |       2 ++
         M config.h                            |       2 ++
         M dwm.c                               |      24 ++++++++++++++++++++++++
       
       3 files changed, 28 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/config.def.h b/config.def.h
       @@ -100,6 +100,8 @@ static const Key keys[] = {
                { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
                { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
                { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
       +        { MODKEY,                       XK_Left,   viewtoleft,     {0} },
       +        { MODKEY,                       XK_Right,  viewtoright,    {0} },
                TAGKEYS(                        XK_1,                      0)
                TAGKEYS(                        XK_2,                      1)
                TAGKEYS(                        XK_3,                      2)
 (DIR) diff --git a/config.h b/config.h
       @@ -128,6 +128,8 @@ static const Key keys[] = {
                { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
                { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
                { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
       +        { MODKEY,                       XK_Left,   viewtoleft,     {0} },
       +        { MODKEY,                       XK_Right,  viewtoright,    {0} },
                TAGKEYS(                        XK_1,                      0)
                TAGKEYS(                        XK_2,                      1)
                TAGKEYS(                        XK_3,                      2)
 (DIR) diff --git a/dwm.c b/dwm.c
       @@ -260,6 +260,8 @@ static void updatetitle(Client *c);
        static void updatewindowtype(Client *c);
        static void updatewmhints(Client *c);
        static void view(const Arg *arg);
       +static void viewtoleft(const Arg *arg);
       +static void viewtoright(const Arg *arg);
        static Client *wintoclient(Window w);
        static Monitor *wintomon(Window w);
        static Client *wintosystrayicon(Window w);
       @@ -2605,6 +2607,28 @@ view(const Arg *arg)
                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;
       +                selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
       +                focus(NULL);
       +                arrange(selmon);
       +        }
       +}
       +
        Client *
        wintoclient(Window w)
        {