dwm-cycleview-20241121-0a129d5f.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-cycleview-20241121-0a129d5f.diff (2008B)
       ---
            1 From 0a129d5ff1b94cf29d0896e9b47a3bc08d6a95fc Mon Sep 17 00:00:00 2001
            2 From: Wim Stockman <wim@thinkerwim.org>
            3 Date: Thu, 21 Nov 2024 15:37:49 +0100
            4 Subject: [PATCH] A patch that loops through all tags on a moniter in both
            5  directions
            6 
            7 ---
            8  config.def.h |  2 ++
            9  dwm.c        | 16 ++++++++++++++++
           10  2 files changed, 18 insertions(+)
           11 
           12 diff --git a/config.def.h b/config.def.h
           13 index 9efa774..04bb388 100644
           14 --- a/config.def.h
           15 +++ b/config.def.h
           16 @@ -67,6 +67,8 @@ static const Key keys[] = {
           17          { MODKEY,                       XK_b,      togglebar,      {0} },
           18          { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
           19          { MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
           20 +        { MODKEY|ShiftMask,             XK_j,      cycleview,      {1} },
           21 +        { MODKEY|ShiftMask,             XK_k,      cycleview,      {0} },
           22          { MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
           23          { MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
           24          { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
           25 diff --git a/dwm.c b/dwm.c
           26 index 1443802..2014518 100644
           27 --- a/dwm.c
           28 +++ b/dwm.c
           29 @@ -226,6 +226,7 @@ static void updatetitle(Client *c);
           30  static void updatewindowtype(Client *c);
           31  static void updatewmhints(Client *c);
           32  static void view(const Arg *arg);
           33 +static void cycleview(const Arg *arg);
           34  static Client *wintoclient(Window w);
           35  static Monitor *wintomon(Window w);
           36  static int xerror(Display *dpy, XErrorEvent *ee);
           37 @@ -2049,6 +2050,21 @@ updatewmhints(Client *c)
           38          }
           39  }
           40  
           41 +void
           42 +cycleview(const Arg *arg) {
           43 +         unsigned int newtag ;
           44 +        if (arg->ui) { /* if ui is 1 goto the left if 0 goto the right */
           45 +            newtag = selmon->tagset[selmon->seltags] >> 1;
           46 +            if (newtag == 0) newtag = (1 << (LENGTH(tags) - 1));
           47 +        }
           48 +        else{
           49 +            newtag = selmon->tagset[selmon->seltags] << 1;
           50 +            if (newtag > ( 1 << (LENGTH(tags) - 1))) newtag = 1;
           51 +        }
           52 +    Arg a = { .ui = newtag};
           53 +    view(&a);
           54 +}
           55 +
           56  void
           57  view(const Arg *arg)
           58  {
           59 -- 
           60 2.47.0
           61