My build of dwm
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dwm-attachbelow-toggleable-6.2.diff 5.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. From ee036687ed9e1bb973b9e34694a57cf5dd67652d Mon Sep 17 00:00:00 2001
  2. From: Jonathan Hodgson <git@jonathanh.co.uk>
  3. Date: Mon, 6 May 2019 18:34:40 +0100
  4. Subject: [PATCH 1/4] Adds attach below option
  5. ---
  6. config.def.h | 1 +
  7. dwm.c | 31 ++++++++++++++++++++++++++++---
  8. 2 files changed, 29 insertions(+), 3 deletions(-)
  9. diff --git a/config.def.h b/config.def.h
  10. index 1c0b587..51ad933 100644
  11. --- a/config.def.h
  12. +++ b/config.def.h
  13. @@ -35,6 +35,7 @@ static const Rule rules[] = {
  14. static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
  15. static const int nmaster = 1; /* number of clients in master area */
  16. static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
  17. +static const int attachbelow = 1; /* 1 means attach at the end */
  18. static const Layout layouts[] = {
  19. /* symbol arrange function */
  20. diff --git a/dwm.c b/dwm.c
  21. index 4465af1..bd715a2 100644
  22. --- a/dwm.c
  23. +++ b/dwm.c
  24. @@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
  25. static void arrange(Monitor *m);
  26. static void arrangemon(Monitor *m);
  27. static void attach(Client *c);
  28. +static void attachBelow(Client *c);
  29. static void attachstack(Client *c);
  30. static void buttonpress(XEvent *e);
  31. static void checkotherwm(void);
  32. @@ -405,6 +406,21 @@ attach(Client *c)
  33. c->next = c->mon->clients;
  34. c->mon->clients = c;
  35. }
  36. +void
  37. +attachBelow(Client *c)
  38. +{
  39. + //If there is nothing on the monitor or the selected client is floating, attach as normal
  40. + if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating) {
  41. + attach(c);
  42. + return;
  43. + }
  44. +
  45. + //Set the new client's next property to the same as the currently selected clients next
  46. + c->next = c->mon->sel->next;
  47. + //Set the currently selected clients next property to the new client
  48. + c->mon->sel->next = c;
  49. +
  50. +}
  51. void
  52. attachstack(Client *c)
  53. @@ -1062,7 +1078,10 @@ manage(Window w, XWindowAttributes *wa)
  54. c->isfloating = c->oldstate = trans != None || c->isfixed;
  55. if (c->isfloating)
  56. XRaiseWindow(dpy, c->win);
  57. - attach(c);
  58. + if( attachbelow )
  59. + attachBelow(c);
  60. + else
  61. + attach(c);
  62. attachstack(c);
  63. XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  64. (unsigned char *) &(c->win), 1);
  65. @@ -1417,7 +1436,10 @@ sendmon(Client *c, Monitor *m)
  66. detachstack(c);
  67. c->mon = m;
  68. c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
  69. - attach(c);
  70. + if( attachbelow )
  71. + attachBelow(c);
  72. + else
  73. + attach(c);
  74. attachstack(c);
  75. focus(NULL);
  76. arrange(NULL);
  77. @@ -1897,7 +1919,10 @@ updategeom(void)
  78. m->clients = c->next;
  79. detachstack(c);
  80. c->mon = mons;
  81. - attach(c);
  82. + if( attachbelow )
  83. + attachBelow(c);
  84. + else
  85. + attach(c);
  86. attachstack(c);
  87. }
  88. if (m == selmon)
  89. --
  90. 2.21.0
  91. From e212c1d8cbdcc56c33c717131dfa7c1689e27e9f Mon Sep 17 00:00:00 2001
  92. From: Jonathan Hodgson <git@jonathanh.co.uk>
  93. Date: Mon, 6 May 2019 19:27:57 +0100
  94. Subject: [PATCH 2/4] fixes comment
  95. ---
  96. config.def.h | 2 +-
  97. 1 file changed, 1 insertion(+), 1 deletion(-)
  98. diff --git a/config.def.h b/config.def.h
  99. index 51ad933..cb8053a 100644
  100. --- a/config.def.h
  101. +++ b/config.def.h
  102. @@ -35,7 +35,7 @@ static const Rule rules[] = {
  103. static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
  104. static const int nmaster = 1; /* number of clients in master area */
  105. static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
  106. -static const int attachbelow = 1; /* 1 means attach at the end */
  107. +static const int attachbelow = 1; /* 1 means attach after the currently active window */
  108. static const Layout layouts[] = {
  109. /* symbol arrange function */
  110. --
  111. 2.21.0
  112. From 7568ea3f8756e7e82b30c4943556ae646a445d1c Mon Sep 17 00:00:00 2001
  113. From: Jonathan Hodgson <git@jonathanh.co.uk>
  114. Date: Mon, 6 May 2019 20:00:30 +0100
  115. Subject: [PATCH 3/4] Makes changes to man page to reflect attach below patch
  116. ---
  117. dwm.1 | 3 +++
  118. 1 file changed, 3 insertions(+)
  119. diff --git a/dwm.1 b/dwm.1
  120. index 13b3729..fb6e76c 100644
  121. --- a/dwm.1
  122. +++ b/dwm.1
  123. @@ -29,6 +29,9 @@ color. The tags of the focused window are indicated with a filled square in the
  124. top left corner. The tags which are applied to one or more windows are
  125. indicated with an empty square in the top left corner.
  126. .P
  127. +The attach below patch makes newly spawned windows attach after the currently
  128. +selected window
  129. +.P
  130. dwm draws a small border around windows to indicate the focus state.
  131. .SH OPTIONS
  132. .TP
  133. --
  134. 2.21.0
  135. From 362b95a5b9f91673f27f3e3343b5738df3c9d6e9 Mon Sep 17 00:00:00 2001
  136. From: Jonathan Hodgson <git@jonathanh.co.uk>
  137. Date: Sun, 2 Jun 2019 15:11:57 +0100
  138. Subject: [PATCH 4/4] Allows attach below to be toggled
  139. ---
  140. config.def.h | 2 +-
  141. dwm.c | 6 ++++++
  142. 2 files changed, 7 insertions(+), 1 deletion(-)
  143. diff --git a/config.def.h b/config.def.h
  144. index cb8053a..b4d35aa 100644
  145. --- a/config.def.h
  146. +++ b/config.def.h
  147. @@ -35,7 +35,7 @@ static const Rule rules[] = {
  148. static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
  149. static const int nmaster = 1; /* number of clients in master area */
  150. static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
  151. -static const int attachbelow = 1; /* 1 means attach after the currently active window */
  152. +static int attachbelow = 1; /* 1 means attach after the currently active window */
  153. static const Layout layouts[] = {
  154. /* symbol arrange function */
  155. diff --git a/dwm.c b/dwm.c
  156. index bd715a2..5d88653 100644
  157. --- a/dwm.c
  158. +++ b/dwm.c
  159. @@ -148,6 +148,7 @@ static void arrange(Monitor *m);
  160. static void arrangemon(Monitor *m);
  161. static void attach(Client *c);
  162. static void attachBelow(Client *c);
  163. +static void toggleAttachBelow();
  164. static void attachstack(Client *c);
  165. static void buttonpress(XEvent *e);
  166. static void checkotherwm(void);
  167. @@ -422,6 +423,11 @@ attachBelow(Client *c)
  168. }
  169. +void toggleAttachBelow()
  170. +{
  171. + attachbelow = !attachbelow;
  172. +}
  173. +
  174. void
  175. attachstack(Client *c)
  176. {
  177. --
  178. 2.21.0