dwm-layoutscroll-6.5.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-layoutscroll-6.5.diff (1995B)
       ---
            1 diff --git a/config.def.h b/config.def.h
            2 index 9efa774..d06afaf 100644
            3 --- a/config.def.h
            4 +++ b/config.def.h
            5 @@ -85,6 +85,8 @@ static const Key keys[] = {
            6          { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
            7          { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
            8          { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
            9 +        { MODKEY|ShiftMask,             XK_h,      layoutscroll,   {.i = -1 } },
           10 +        { MODKEY|ShiftMask,             XK_l,      layoutscroll,   {.i = +1 } },
           11          TAGKEYS(                        XK_1,                      0)
           12          TAGKEYS(                        XK_2,                      1)
           13          TAGKEYS(                        XK_3,                      2)
           14 diff --git a/dwm.c b/dwm.c
           15 index 1443802..b2271d9 100644
           16 --- a/dwm.c
           17 +++ b/dwm.c
           18 @@ -129,6 +129,7 @@ struct Monitor {
           19          Monitor *next;
           20          Window barwin;
           21          const Layout *lt[2];
           22 +        int ltcur; /* current layout */
           23  };
           24  
           25  typedef struct {
           26 @@ -199,6 +200,7 @@ static void sendmon(Client *c, Monitor *m);
           27  static void setclientstate(Client *c, long state);
           28  static void setfocus(Client *c);
           29  static void setfullscreen(Client *c, int fullscreen);
           30 +static void layoutscroll(const Arg *arg);
           31  static void setlayout(const Arg *arg);
           32  static void setmfact(const Arg *arg);
           33  static void setup(void);
           34 @@ -640,6 +642,7 @@ createmon(void)
           35          m->nmaster = nmaster;
           36          m->showbar = showbar;
           37          m->topbar = topbar;
           38 +        m->ltcur = 0;
           39          m->lt[0] = &layouts[0];
           40          m->lt[1] = &layouts[1 % LENGTH(layouts)];
           41          strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
           42 @@ -1506,6 +1509,25 @@ setfullscreen(Client *c, int fullscreen)
           43          }
           44  }
           45  
           46 +void
           47 +layoutscroll(const Arg *arg)
           48 +{
           49 +        if (!arg || !arg->i)
           50 +                return;
           51 +        int switchto = selmon->ltcur + arg->i;
           52 +        int l = LENGTH(layouts);
           53 +
           54 +        if (switchto >= l)
           55 +                switchto = 0;
           56 +        else if(switchto < 0)
           57 +                switchto = l - 1;
           58 +
           59 +        selmon->ltcur = switchto;
           60 +        Arg arg2 = {.v= &layouts[switchto] };
           61 +        setlayout(&arg2);
           62 +
           63 +}
           64 +
           65  void
           66  setlayout(const Arg *arg)
           67  {