dwm-cfacts-20200913-61bb8b2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-cfacts-20200913-61bb8b2.diff (3596B)
       ---
            1 From c32a879432573d71dec7fcb4bf68927d2f4cdf10 Mon Sep 17 00:00:00 2001
            2 From: iofq <cjriddz@protonmail.com>
            3 Date: Sat, 12 Sep 2020 22:28:09 -0500
            4 Subject: [PATCH] Fixed 'cfacts' patch failure due to upstream commit
            5  'f09418bbb...'
            6 
            7 ---
            8  config.def.h |  3 +++
            9  dwm.c        | 34 +++++++++++++++++++++++++++++++---
           10  2 files changed, 34 insertions(+), 3 deletions(-)
           11 
           12 diff --git a/config.def.h b/config.def.h
           13 index 1c0b587..83910c1 100644
           14 --- a/config.def.h
           15 +++ b/config.def.h
           16 @@ -70,6 +70,9 @@ static Key keys[] = {
           17          { MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
           18          { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
           19          { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
           20 +        { MODKEY|ShiftMask,             XK_h,      setcfact,       {.f = +0.25} },
           21 +        { MODKEY|ShiftMask,             XK_l,      setcfact,       {.f = -0.25} },
           22 +        { MODKEY|ShiftMask,             XK_o,      setcfact,       {.f =  0.00} },
           23          { MODKEY,                       XK_Return, zoom,           {0} },
           24          { MODKEY,                       XK_Tab,    view,           {0} },
           25          { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
           26 diff --git a/dwm.c b/dwm.c
           27 index 664c527..5233229 100644
           28 --- a/dwm.c
           29 +++ b/dwm.c
           30 @@ -87,6 +87,7 @@ typedef struct Client Client;
           31  struct Client {
           32          char name[256];
           33          float mina, maxa;
           34 +        float cfact;
           35          int x, y, w, h;
           36          int oldx, oldy, oldw, oldh;
           37          int basew, baseh, incw, inch, maxw, maxh, minw, minh;
           38 @@ -201,6 +202,7 @@ static void setclientstate(Client *c, long state);
           39  static void setfocus(Client *c);
           40  static void setfullscreen(Client *c, int fullscreen);
           41  static void setlayout(const Arg *arg);
           42 +static void setcfact(const Arg *arg);
           43  static void setmfact(const Arg *arg);
           44  static void setup(void);
           45  static void seturgent(Client *c, int urg);
           46 @@ -1030,6 +1032,7 @@ manage(Window w, XWindowAttributes *wa)
           47          c->w = c->oldw = wa->width;
           48          c->h = c->oldh = wa->height;
           49          c->oldbw = wa->border_width;
           50 +        c->cfact = 1.0;
           51  
           52          updatetitle(c);
           53          if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
           54 @@ -1512,6 +1515,23 @@ setlayout(const Arg *arg)
           55                  drawbar(selmon);
           56  }
           57  
           58 +void setcfact(const Arg *arg) {
           59 +        float f;
           60 +        Client *c;
           61 +
           62 +        c = selmon->sel;
           63 +
           64 +        if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
           65 +                return;
           66 +        f = arg->f + c->cfact;
           67 +        if(arg->f == 0.0)
           68 +                f = 1.0;
           69 +        else if(f < 0.25 || f > 4.0)
           70 +                return;
           71 +        c->cfact = f;
           72 +        arrange(selmon);
           73 +}
           74 +
           75  /* arg > 1.0 will set mfact absolutely */
           76  void
           77  setmfact(const Arg *arg)
           78 @@ -1675,9 +1695,15 @@ void
           79  tile(Monitor *m)
           80  {
           81          unsigned int i, n, h, mw, my, ty;
           82 +        float mfacts = 0, sfacts = 0;
           83          Client *c;
           84  
           85 -        for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
           86 +        for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
           87 +                if (n < m->nmaster)
           88 +                        mfacts += c->cfact;
           89 +                else
           90 +                        sfacts += c->cfact;
           91 +        }
           92          if (n == 0)
           93                  return;
           94  
           95 @@ -1687,15 +1713,17 @@ tile(Monitor *m)
           96                  mw = m->ww;
           97          for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
           98                  if (i < m->nmaster) {
           99 -                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
          100 +                        h = (m->wh - my) * (c->cfact / mfacts);
          101                          resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
          102                          if (my + HEIGHT(c) < m->wh)
          103                                  my += HEIGHT(c);
          104 +     mfacts -= c->cfact;
          105                  } else {
          106 -                        h = (m->wh - ty) / (n - i);
          107 +                        h = (m->wh - ty) * (c->cfact / sfacts);
          108                          resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
          109                          if (ty + HEIGHT(c) < m->wh)
          110                                  ty += HEIGHT(c);
          111 +     sfacts -= c->cfact;
          112                  }
          113  }
          114  
          115 -- 
          116 2.28.0
          117