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.

113 lines
3.8 KiB

4 years ago
  1. From 3aca05f642469799086acbc243e173cfda527683 Mon Sep 17 00:00:00 2001
  2. From: aleks <aleks.stier@icloud.com>
  3. Date: Thu, 23 May 2019 22:39:13 +0200
  4. Subject: [PATCH] Enable swapping master- and stack-area
  5. Enables swapping the master- and stack area such that the master-client
  6. appears on the right and the stack-clients appear on the left.
  7. A variable and a toggle-function are introduced to achieve this
  8. behaviour which are set in the config.h:
  9. * The rmaster-variable can be set to 1 to make the right area the
  10. default master-area
  11. * The togglemaster-function can be used to swap the master- and
  12. stack-areas dynamically.
  13. ---
  14. config.def.h | 2 ++
  15. dwm.c | 23 ++++++++++++++++++++---
  16. 2 files changed, 22 insertions(+), 3 deletions(-)
  17. diff --git a/config.def.h b/config.def.h
  18. index 7054c06..5a69035 100644
  19. --- a/config.def.h
  20. +++ b/config.def.h
  21. @@ -13,6 +13,7 @@ static const char selbgcolor[] = "#005577";
  22. static const char selfgcolor[] = "#eeeeee";
  23. static const unsigned int borderpx = 1; /* border pixel of windows */
  24. static const unsigned int snap = 32; /* snap pixel */
  25. +static const int rmaster = 1; /* 1 means master-area is initially on the right */
  26. static const int showbar = 1; /* 0 means no bar */
  27. static const int topbar = 1; /* 0 means bottom bar */
  28. @@ -76,6 +77,7 @@ static Key keys[] = {
  29. { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
  30. { MODKEY, XK_space, setlayout, {0} },
  31. { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
  32. + { MODKEY, XK_r, togglermaster, {0} },
  33. { MODKEY, XK_0, view, {.ui = ~0 } },
  34. { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
  35. { MODKEY, XK_comma, focusmon, {.i = -1 } },
  36. diff --git a/dwm.c b/dwm.c
  37. index 0362114..e11bd8b 100644
  38. --- a/dwm.c
  39. +++ b/dwm.c
  40. @@ -122,6 +122,7 @@ struct Monitor {
  41. unsigned int seltags;
  42. unsigned int sellt;
  43. unsigned int tagset[2];
  44. + int rmaster;
  45. int showbar;
  46. int topbar;
  47. Client *clients;
  48. @@ -211,6 +212,7 @@ static void tagmon(const Arg *arg);
  49. static void tile(Monitor *);
  50. static void togglebar(const Arg *arg);
  51. static void togglefloating(const Arg *arg);
  52. +static void togglermaster(const Arg *arg);
  53. static void toggletag(const Arg *arg);
  54. static void toggleview(const Arg *arg);
  55. static void unfocus(Client *c, int setfocus);
  56. @@ -645,6 +647,7 @@ createmon(void)
  57. m->tagset[0] = m->tagset[1] = 1;
  58. m->mfact = mfact;
  59. m->nmaster = nmaster;
  60. + m->rmaster = rmaster;
  61. m->showbar = showbar;
  62. m->topbar = topbar;
  63. m->lt[0] = &layouts[0];
  64. @@ -1674,17 +1677,21 @@ tile(Monitor *m)
  65. return;
  66. if (n > m->nmaster)
  67. - mw = m->nmaster ? m->ww * m->mfact : 0;
  68. + mw = m->nmaster
  69. + ? m->ww * (m->rmaster ? 1.0 - m->mfact : m->mfact)
  70. + : 0;
  71. else
  72. mw = m->ww;
  73. for (i = my = ty = 0, 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);
  76. - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  77. + resize(c, m->rmaster ? m->wx + m->ww - mw : m->wx,
  78. + m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  79. my += HEIGHT(c);
  80. } else {
  81. h = (m->wh - ty) / (n - i);
  82. - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  83. + resize(c, m->rmaster ? m->wx : m->wx + mw, m->wy + ty,
  84. + m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  85. ty += HEIGHT(c);
  86. }
  87. }
  88. @@ -1712,6 +1719,16 @@ togglefloating(const Arg *arg)
  89. arrange(selmon);
  90. }
  91. +void
  92. +togglermaster(const Arg *arg)
  93. +{
  94. + selmon->rmaster = !selmon->rmaster;
  95. + /* now mfact represents the left factor */
  96. + selmon->mfact = 1.0 - selmon->mfact;
  97. + if (selmon->lt[selmon->sellt]->arrange)
  98. + arrange(selmon);
  99. +}
  100. +
  101. void
  102. toggletag(const Arg *arg)
  103. {
  104. --
  105. 2.21.0