dwm-cfacts-6.2.diff 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. diff -uraN a/config.def.h b/config.def.h
  2. --- a/config.def.h 2019-02-02 15:55:28.000000000 +0300
  3. +++ b/config.def.h 2020-02-18 03:33:58.212113667 +0300
  4. @@ -70,6 +70,9 @@
  5. { MODKEY, XK_d, incnmaster, {.i = -1 } },
  6. { MODKEY, XK_h, setmfact, {.f = -0.05} },
  7. { MODKEY, XK_l, setmfact, {.f = +0.05} },
  8. + { MODKEY|ShiftMask, XK_h, setcfact, {.f = +0.25} },
  9. + { MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} },
  10. + { MODKEY|ShiftMask, XK_o, setcfact, {.f = 0.00} },
  11. { MODKEY, XK_Return, zoom, {0} },
  12. { MODKEY, XK_Tab, view, {0} },
  13. { MODKEY|ShiftMask, XK_c, killclient, {0} },
  14. diff -uraN a/dwm.c b/dwm.c
  15. --- a/dwm.c 2019-02-02 15:55:28.000000000 +0300
  16. +++ b/dwm.c 2020-02-18 03:33:58.213447007 +0300
  17. @@ -87,6 +87,7 @@
  18. struct Client {
  19. char name[256];
  20. float mina, maxa;
  21. + float cfact;
  22. int x, y, w, h;
  23. int oldx, oldy, oldw, oldh;
  24. int basew, baseh, incw, inch, maxw, maxh, minw, minh;
  25. @@ -200,6 +201,7 @@
  26. static void setfocus(Client *c);
  27. static void setfullscreen(Client *c, int fullscreen);
  28. static void setlayout(const Arg *arg);
  29. +static void setcfact(const Arg *arg);
  30. static void setmfact(const Arg *arg);
  31. static void setup(void);
  32. static void seturgent(Client *c, int urg);
  33. @@ -1029,6 +1031,7 @@
  34. c->w = c->oldw = wa->width;
  35. c->h = c->oldh = wa->height;
  36. c->oldbw = wa->border_width;
  37. + c->cfact = 1.0;
  38. updatetitle(c);
  39. if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
  40. @@ -1511,6 +1514,23 @@
  41. drawbar(selmon);
  42. }
  43. +void setcfact(const Arg *arg) {
  44. + float f;
  45. + Client *c;
  46. +
  47. + c = selmon->sel;
  48. +
  49. + if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
  50. + return;
  51. + f = arg->f + c->cfact;
  52. + if(arg->f == 0.0)
  53. + f = 1.0;
  54. + else if(f < 0.25 || f > 4.0)
  55. + return;
  56. + c->cfact = f;
  57. + arrange(selmon);
  58. +}
  59. +
  60. /* arg > 1.0 will set mfact absolutely */
  61. void
  62. setmfact(const Arg *arg)
  63. @@ -1674,9 +1694,15 @@
  64. tile(Monitor *m)
  65. {
  66. unsigned int i, n, h, mw, my, ty;
  67. + float mfacts = 0, sfacts = 0;
  68. Client *c;
  69. - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  70. + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
  71. + if (n < m->nmaster)
  72. + mfacts += c->cfact;
  73. + else
  74. + sfacts += c->cfact;
  75. + }
  76. if (n == 0)
  77. return;
  78. @@ -1686,13 +1712,15 @@
  79. mw = m->ww;
  80. for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  81. if (i < m->nmaster) {
  82. - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  83. + h = (m->wh - my) * (c->cfact / mfacts);
  84. resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  85. my += HEIGHT(c);
  86. + mfacts -= c->cfact;
  87. } else {
  88. h = (m->wh - ty) / (n - i);
  89. resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  90. ty += HEIGHT(c);
  91. + sfacts -= c->cfact;
  92. }
  93. }