dwm-stairs-fullgaps-20220430-8b48e30.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-stairs-fullgaps-20220430-8b48e30.diff (3702B)
       ---
            1 From 2004db267a9478918699961ab2f3579c2c8113fb Mon Sep 17 00:00:00 2001
            2 From: Ehsan Ghorbannezhad <ehsan@disroot.org>
            3 Date: Sat, 30 Apr 2022 02:48:58 +0430
            4 Subject: [PATCH] add the stairs layout with fullgaps support
            5 
            6 ---
            7  config.def.h |  5 +++++
            8  dwm.c        | 38 ++++++++++++++++++++++++++++++++++++++
            9  2 files changed, 43 insertions(+)
           10 
           11 diff --git a/config.def.h b/config.def.h
           12 index 5b0d4de..c0f24f4 100644
           13 --- a/config.def.h
           14 +++ b/config.def.h
           15 @@ -6,6 +6,9 @@ static const unsigned int gappx     = 5;        /* gaps between windows */
           16  static const unsigned int snap      = 32;       /* snap pixel */
           17  static const int showbar            = 1;        /* 0 means no bar */
           18  static const int topbar             = 1;        /* 0 means bottom bar */
           19 +static const unsigned int stairpx   = 20;       /* depth of the stairs layout */
           20 +static const int stairdirection     = 1;        /* 0: left-aligned, 1: right-aligned */
           21 +static const int stairsamesize      = 1;        /* 1 means shrink all the staired windows to the same size */
           22  static const char *fonts[]          = { "monospace:size=10" };
           23  static const char dmenufont[]       = "monospace:size=10";
           24  static const char col_gray1[]       = "#222222";
           25 @@ -43,6 +46,7 @@ static const Layout layouts[] = {
           26          { "[]=",      tile },    /* first entry is default */
           27          { "><>",      NULL },    /* no layout function means floating behavior */
           28          { "[M]",      monocle },
           29 +        { "[S]",      stairs },
           30  };
           31 
           32  /* key definitions */
           33 @@ -78,6 +82,7 @@ static Key keys[] = {
           34          { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
           35          { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
           36          { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
           37 +        { MODKEY,                       XK_s,      setlayout,      {.v = &layouts[3]} },
           38          { MODKEY,                       XK_space,  setlayout,      {0} },
           39          { MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
           40          { MODKEY,                       XK_0,      view,           {.ui = ~0 } },
           41 diff --git a/dwm.c b/dwm.c
           42 index 5b7348c..2c5380f 100644
           43 --- a/dwm.c
           44 +++ b/dwm.c
           45 @@ -209,6 +209,7 @@ static void seturgent(Client *c, int urg);
           46  static void showhide(Client *c);
           47  static void sigchld(int unused);
           48  static void spawn(const Arg *arg);
           49 +static void stairs(Monitor *m);
           50  static void tag(const Arg *arg);
           51  static void tagmon(const Arg *arg);
           52  static void tile(Monitor *);
           53 @@ -1672,6 +1673,43 @@ spawn(const Arg *arg)
           54          }
           55  }
           56 
           57 +void
           58 +stairs(Monitor *m)
           59 +{
           60 +        unsigned int i, n, h, mw, my;
           61 +        unsigned int ox, oy, ow, oh; /* stair offset values */
           62 +        Client *c;
           63 +
           64 +        for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
           65 +        if (n == 0)
           66 +                return;
           67 +
           68 +        if (n > m->nmaster)
           69 +                mw = m->nmaster ? m->ww * m->mfact : 0;
           70 +        else
           71 +                mw = m->ww - m->gappx;
           72 +
           73 +        for (i = 0, my = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
           74 +                if (i < m->nmaster) {
           75 +                        h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
           76 +                        resize(c, m->wx + m->gappx, m->wy + my, mw - (2 * c->bw) - m->gappx, h - (2 * c->bw), 0);
           77 +                        if (my + HEIGHT(c) + m->gappx < m->wh)
           78 +                                my += HEIGHT(c) + m->gappx;
           79 +                } else {
           80 +                        oy = i - m->nmaster;
           81 +                        ox = stairdirection ? n - i - 1 : (stairsamesize ? i - m->nmaster : 0);
           82 +                        ow = stairsamesize ? n - m->nmaster - 1 : n - i - 1;
           83 +                        oh = stairsamesize ? ow : i - m->nmaster;
           84 +                        resize(c,
           85 +                               m->wx + mw + (ox * stairpx) + m->gappx,
           86 +                               m->wy + (oy * stairpx) + m->gappx,
           87 +                               m->ww - mw - (2 * c->bw) - (ow * stairpx) - (2 * m->gappx),
           88 +                               m->wh - (2 * c->bw) - (oh * stairpx) - (2 * m->gappx),
           89 +                               0);
           90 +                }
           91 +        }
           92 +}
           93 +
           94  void
           95  tag(const Arg *arg)
           96  {
           97 --
           98 2.36.0