Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.4 KiB

  1. void
  2. centeredfloatingmaster(Monitor *m)
  3. {
  4. unsigned int i, n;
  5. float mfacts, sfacts;
  6. int mrest, srest;
  7. int mx = 0, my = 0, mh = 0, mw = 0;
  8. int sx = 0, sy = 0, sh = 0, sw = 0;
  9. Client *c;
  10. #if VANITYGAPS_PATCH
  11. float mivf = 1.0; // master inner vertical gap factor
  12. int oh, ov, ih, iv;
  13. getgaps(m, &oh, &ov, &ih, &iv, &n);
  14. #else
  15. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  16. #endif // VANITYGAPS_PATCH
  17. if (n == 0)
  18. return;
  19. #if VANITYGAPS_PATCH
  20. sx = mx = m->wx + ov;
  21. sy = my = m->wy + oh;
  22. sh = mh = m->wh - 2*oh;
  23. mw = m->ww - 2*ov - iv*(n - 1);
  24. sw = m->ww - 2*ov - iv*(n - m->nmaster - 1);
  25. if (m->nmaster && n > m->nmaster) {
  26. mivf = 0.8;
  27. /* go mfact box in the center if more than nmaster clients */
  28. if (m->ww > m->wh) {
  29. mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1);
  30. mh = m->wh * 0.9;
  31. } else {
  32. mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1);
  33. mh = m->wh * m->mfact;
  34. }
  35. mx = m->wx + (m->ww - mw) / 2;
  36. my = m->wy + (m->wh - mh - 2*oh) / 2;
  37. sx = m->wx + ov;
  38. sy = m->wy + oh;
  39. sh = m->wh - 2*oh;
  40. }
  41. #else
  42. sx = mx = m->wx;
  43. sy = my = m->wy;
  44. sh = mh = m->wh;
  45. sw = mw = m->ww;
  46. if (m->nmaster && n > m->nmaster) {
  47. /* go mfact box in the center if more than nmaster clients */
  48. if (m->ww > m->wh) {
  49. mw = m->ww * m->mfact;
  50. mh = m->wh * 0.9;
  51. } else {
  52. mw = m->ww * 0.9;
  53. mh = m->wh * m->mfact;
  54. }
  55. mx = m->wx + (m->ww - mw) / 2;
  56. my = m->wy + (m->wh - mh) / 2;
  57. }
  58. #endif // VANITYGAPS_PATCH
  59. getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest);
  60. for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  61. if (i < m->nmaster) {
  62. /* nmaster clients are stacked horizontally, in the center of the screen */
  63. #if CFACTS_PATCH
  64. resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
  65. #else
  66. resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
  67. #endif // CFACTS_PATCH
  68. #if VANITYGAPS_PATCH
  69. mx += WIDTH(c) + iv*mivf;
  70. #else
  71. mx += WIDTH(c);
  72. #endif
  73. } else {
  74. /* stack clients are stacked horizontally */
  75. #if CFACTS_PATCH
  76. resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
  77. #else
  78. resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
  79. #endif // CFACTS_PATCH
  80. #if VANITYGAPS_PATCH
  81. sx += WIDTH(c) + iv;
  82. #else
  83. sx += WIDTH(c);
  84. #endif
  85. }
  86. }