Advertisement
robcsi

Gaps patch for InstanWM

Sep 27th, 2020 (edited)
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.59 KB | None | 0 0
  1. diff --git a/config.def.h b/config.def.h
  2. index f50c13e..83c69f4 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -11,6 +11,7 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display sy
  6.  static const int showsystray = 1;            /* 0 means no systray */
  7.  static const int showbar = 1;                /* 0 means no bar */
  8.  static const int topbar = 1;                 /* 0 means bottom bar */
  9. +static const int gappx = 10;
  10.  static const char *fonts[] = {"Cantarell-Regular:size=12", "Fira Code Nerd Font:size=12"};
  11.  
  12.  static int barheight;
  13. @@ -391,6 +392,10 @@ static Key keys[] = {
  14.  
  15.     { MODKEY, XK_o, winview, {0} },
  16.  
  17. +   { MODKEY,                       XK_minus,  setgaps,        {.i = -5 } },
  18. +    { MODKEY,                       XK_equal,  setgaps,        {.i = +5 } },
  19. +   { MODKEY|ShiftMask,             XK_equal,  setgaps,        {.i = 0  } },
  20. +
  21.  };
  22.  
  23.  /* button definitions */
  24. diff --git a/instantwm.c b/instantwm.c
  25. index f9b8d9f..751feb4 100644
  26. --- a/instantwm.c
  27. +++ b/instantwm.c
  28. @@ -1119,6 +1119,7 @@ createmon(void)
  29.     m->nmaster = nmaster;
  30.     m->showbar = showbar;
  31.     m->topbar = topbar;
  32. +    m->gappx = gappx;
  33.     m->clientcount = 0;
  34.      m->overlaymode = 0;
  35.     m->scratchvisible = 0;
  36. @@ -3703,6 +3704,16 @@ setfullscreen(Client *c, int fullscreen)
  37.     }
  38.  }
  39.  
  40. +void
  41. +setgaps(const Arg *arg)
  42. +{
  43. +   if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
  44. +       selmon->gappx = 0;
  45. +   else
  46. +       selmon->gappx += arg->i;
  47. +   arrange(selmon);
  48. +}
  49. +
  50.  void
  51.  setlayout(const Arg *arg)
  52.  {
  53. diff --git a/instantwm.h b/instantwm.h
  54. index de572d4..7cf6a96 100644
  55. --- a/instantwm.h
  56. +++ b/instantwm.h
  57. @@ -121,6 +121,7 @@ struct Monitor {
  58.     int bt;               /* number of tasks */
  59.     int mx, my, mw, mh;   /* screen size */
  60.     int wx, wy, ww, wh;   /* window area  */
  61. +    int gappx;
  62.     unsigned int seltags;
  63.     unsigned int sellt;
  64.     unsigned int tagset[2];
  65. @@ -261,6 +262,7 @@ int getxtag(int ix);
  66.  void setclientstate(Client *c, long state);
  67.  void setfocus(Client *c);
  68.  void setfullscreen(Client *c, int fullscreen);
  69. +static void setgaps(const Arg* arg);
  70.  void setlayout(const Arg *arg);
  71.  void setmfact(const Arg *arg);
  72.  void setup(void);
  73. diff --git a/layouts.c b/layouts.c
  74. index 9925004..982ec46 100644
  75. --- a/layouts.c
  76. +++ b/layouts.c
  77. @@ -123,15 +123,15 @@ deck(Monitor *m)
  78.     if(n > m->nmaster)
  79.         mw = m->nmaster ? m->ww * m->mfact : 0;
  80.     else
  81. -       mw = m->ww;
  82. -   for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  83. +       mw = m->ww - m->gappx;
  84. +   for(i = 0, my = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  85.         if(i < m->nmaster) {
  86. -           h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  87. -           resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
  88. -           my += HEIGHT(c);
  89. +           h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
  90. +           resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), False);
  91. +           my += HEIGHT(c) + m->gappx;
  92.         }
  93.         else
  94. -           resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
  95. +           resize(c, m->wx + mw + m->gappx, m->wy, m->ww - mw - (2*c->bw) - 2*m->gappx, m->wh - (2*c->bw), False);
  96.  }
  97.  
  98.  void
  99. @@ -354,30 +354,30 @@ tile(Monitor *m)
  100.         return;
  101.  
  102.     if (n > m->nmaster)
  103. -       mw = m->nmaster ? m->ww * m->mfact : 0;
  104. +       mw = m->nmaster ? m->ww * m->mfact - m->gappx : 0;
  105.     else {
  106. -       mw = m->ww;
  107. +       mw = m->ww - m->gappx;
  108.         if (n > 1 && n < m->nmaster) {
  109.             m->nmaster = n;
  110.             tile(m);
  111.             return;
  112.         }
  113.     }
  114. -   for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  115. +   for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  116.         if (i < m->nmaster) {
  117.             // client is in the master
  118. -           h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  119. -           animateclient(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), framecount, 0);
  120. +           h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
  121. +           animateclient(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), framecount, 0);
  122.             if (m->nmaster == 1 && n > 1) {
  123. -               mw = c->w + c->bw * 2;
  124. +               mw = c->w + c->bw * 2 + m->gappx;
  125.             }
  126.             if (my + HEIGHT(c) < m->wh)
  127. -               my += HEIGHT(c);
  128. +               my += HEIGHT(c) + m->gappx;
  129.         } else {
  130.             // client is in the stack
  131. -           h = (m->wh - ty) / (n - i);
  132. -           animateclient(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), framecount, 0);
  133. +           h = (m->wh - ty) / (n - i) - m->gappx;
  134. +           animateclient(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), framecount, 0);
  135.             if (ty + HEIGHT(c) < m->wh)
  136. -               ty += HEIGHT(c);
  137. +               ty += HEIGHT(c) + m->gappx;
  138.         }
  139.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement