My build of dwm
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

249 rindas
6.7 KiB

  1. From 753860d3435e2968358f2bf8daf70bf625fe75fe Mon Sep 17 00:00:00 2001
  2. From: Kajetan Puchalski <kajetan.puchalski@tuta.io>
  3. Date: Mon, 5 Oct 2020 11:04:31 +0100
  4. Subject: [PATCH] Updated Mark patch to work with 6.2
  5. ---
  6. config.h | 14 +++++--
  7. drw.h | 2 +-
  8. dwm.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
  9. 3 files changed, 118 insertions(+), 9 deletions(-)
  10. diff --git a/config.h b/config.h
  11. index 3858d75..a416c97 100644
  12. --- a/config.h
  13. +++ b/config.h
  14. @@ -12,10 +12,13 @@ static const char col_gray2[] = "#444444";
  15. static const char col_gray3[] = "#bbbbbb";
  16. static const char col_gray4[] = "#eeeeee";
  17. static const char col_cyan[] = "#005577";
  18. -static const char *colors[][3] = {
  19. - /* fg bg border */
  20. - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
  21. - [SchemeSel] = { col_gray4, col_cyan, col_cyan },
  22. +static const char normmarkcolor[] = "#775500"; /*border color for marked client*/
  23. +static const char selmarkcolor[] = "#775577"; /*border color for marked client on focus*/
  24. +
  25. +static const char *colors[][4] = {
  26. + /* fg bg border mark */
  27. + [SchemeNorm] = { col_gray3, col_gray1, col_gray2, normmarkcolor },
  28. + [SchemeSel] = { col_gray4, col_cyan, col_cyan, selmarkcolor },
  29. };
  30. /* tagging */
  31. @@ -94,6 +97,9 @@ static Key keys[] = {
  32. TAGKEYS( XK_8, 7)
  33. TAGKEYS( XK_9, 8)
  34. { MODKEY|ShiftMask, XK_q, quit, {0} },
  35. + { MODKEY, XK_semicolon, togglemark, {0} },
  36. + { MODKEY, XK_o, swapfocus, {0} },
  37. + { MODKEY, XK_u, swapclient, {0} },
  38. };
  39. /* button definitions */
  40. diff --git a/drw.h b/drw.h
  41. index 4bcd5ad..97aae99 100644
  42. --- a/drw.h
  43. +++ b/drw.h
  44. @@ -12,7 +12,7 @@ typedef struct Fnt {
  45. struct Fnt *next;
  46. } Fnt;
  47. -enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
  48. +enum { ColFg, ColBg, ColBorder, ColMark }; /* Clr scheme index */
  49. typedef XftColor Clr;
  50. typedef struct {
  51. diff --git a/dwm.c b/dwm.c
  52. index 664c527..195b8eb 100644
  53. --- a/dwm.c
  54. +++ b/dwm.c
  55. @@ -201,17 +201,21 @@ static void setclientstate(Client *c, long state);
  56. static void setfocus(Client *c);
  57. static void setfullscreen(Client *c, int fullscreen);
  58. static void setlayout(const Arg *arg);
  59. +static void setmark(Client *c);
  60. static void setmfact(const Arg *arg);
  61. static void setup(void);
  62. static void seturgent(Client *c, int urg);
  63. static void showhide(Client *c);
  64. static void sigchld(int unused);
  65. static void spawn(const Arg *arg);
  66. +static void swapclient(const Arg *arg);
  67. +static void swapfocus(const Arg *arg);
  68. static void tag(const Arg *arg);
  69. static void tagmon(const Arg *arg);
  70. static void tile(Monitor *);
  71. static void togglebar(const Arg *arg);
  72. static void togglefloating(const Arg *arg);
  73. +static void togglemark(const Arg *arg);
  74. static void toggletag(const Arg *arg);
  75. static void toggleview(const Arg *arg);
  76. static void unfocus(Client *c, int setfocus);
  77. @@ -268,6 +272,7 @@ static Display *dpy;
  78. static Drw *drw;
  79. static Monitor *mons, *selmon;
  80. static Window root, wmcheckwin;
  81. +static Client *mark;
  82. /* configuration, allows nested code to access above variables */
  83. #include "config.h"
  84. @@ -796,7 +801,10 @@ focus(Client *c)
  85. detachstack(c);
  86. attachstack(c);
  87. grabbuttons(c, 1);
  88. - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
  89. + if (c == mark)
  90. + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColMark].pixel);
  91. + else
  92. + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
  93. setfocus(c);
  94. } else {
  95. XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  96. @@ -1052,7 +1060,10 @@ manage(Window w, XWindowAttributes *wa)
  97. wc.border_width = c->bw;
  98. XConfigureWindow(dpy, w, CWBorderWidth, &wc);
  99. - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
  100. + if (c == mark)
  101. + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColMark].pixel);
  102. + else
  103. + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
  104. configure(c); /* propagates border_width, if size doesn't change */
  105. updatewindowtype(c);
  106. updatesizehints(c);
  107. @@ -1512,6 +1523,23 @@ setlayout(const Arg *arg)
  108. drawbar(selmon);
  109. }
  110. +void
  111. +setmark(Client *c)
  112. +{
  113. + if (c == mark)
  114. + return;
  115. + if (mark) {
  116. + XSetWindowBorder(dpy, mark->win, scheme[mark == selmon->sel
  117. + ? SchemeSel : SchemeNorm][ColBorder].pixel);
  118. + mark = 0;
  119. + }
  120. + if (c) {
  121. + XSetWindowBorder(dpy, c->win, scheme[c == selmon->sel
  122. + ? SchemeSel : SchemeNorm][ColMark].pixel);
  123. + mark = c;
  124. + }
  125. +}
  126. +
  127. /* arg > 1.0 will set mfact absolutely */
  128. void
  129. setmfact(const Arg *arg)
  130. @@ -1570,7 +1598,7 @@ setup(void)
  131. /* init appearance */
  132. scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
  133. for (i = 0; i < LENGTH(colors); i++)
  134. - scheme[i] = drw_scm_create(drw, colors[i], 3);
  135. + scheme[i] = drw_scm_create(drw, colors[i], 4);
  136. /* init bars */
  137. updatebars();
  138. updatestatus();
  139. @@ -1653,6 +1681,75 @@ spawn(const Arg *arg)
  140. }
  141. }
  142. +void
  143. +swapclient(const Arg *arg)
  144. +{
  145. + Client *s, *m, t;
  146. +
  147. + if (!mark || !selmon->sel || mark == selmon->sel
  148. + || !selmon->lt[selmon->sellt]->arrange)
  149. + return;
  150. + s = selmon->sel;
  151. + m = mark;
  152. + t = *s;
  153. + strcpy(s->name, m->name);
  154. + s->win = m->win;
  155. + s->x = m->x;
  156. + s->y = m->y;
  157. + s->w = m->w;
  158. + s->h = m->h;
  159. +
  160. + m->win = t.win;
  161. + strcpy(m->name, t.name);
  162. + m->x = t.x;
  163. + m->y = t.y;
  164. + m->w = t.w;
  165. + m->h = t.h;
  166. +
  167. + selmon->sel = m;
  168. + mark = s;
  169. + focus(s);
  170. + setmark(m);
  171. +
  172. + arrange(s->mon);
  173. + if (s->mon != m->mon) {
  174. + arrange(m->mon);
  175. + }
  176. +}
  177. +
  178. +void
  179. +swapfocus(const Arg *arg)
  180. +{
  181. + Client *t;
  182. +
  183. + if (!selmon->sel || !mark || selmon->sel == mark)
  184. + return;
  185. + t = selmon->sel;
  186. + if (mark->mon != selmon) {
  187. + unfocus(selmon->sel, 0);
  188. + selmon = mark->mon;
  189. + }
  190. + if (ISVISIBLE(mark)) {
  191. + focus(mark);
  192. + restack(selmon);
  193. + } else {
  194. + selmon->seltags ^= 1;
  195. + selmon->tagset[selmon->seltags] = mark->tags;
  196. + focus(mark);
  197. + arrange(selmon);
  198. + }
  199. + setmark(t);
  200. +}
  201. +
  202. +void
  203. +togglemark(const Arg *arg)
  204. +{
  205. + if (!selmon->sel)
  206. + return;
  207. + setmark(selmon->sel == mark ? 0 : selmon->sel);
  208. +}
  209. +
  210. +
  211. void
  212. tag(const Arg *arg)
  213. {
  214. @@ -1755,7 +1852,10 @@ unfocus(Client *c, int setfocus)
  215. if (!c)
  216. return;
  217. grabbuttons(c, 0);
  218. - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
  219. + if (c == mark)
  220. + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColMark].pixel);
  221. + else
  222. + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
  223. if (setfocus) {
  224. XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  225. XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
  226. @@ -1768,6 +1868,9 @@ unmanage(Client *c, int destroyed)
  227. Monitor *m = c->mon;
  228. XWindowChanges wc;
  229. + if (c == mark)
  230. + setmark(0);
  231. +
  232. detach(c);
  233. detachstack(c);
  234. if (!destroyed) {
  235. --
  236. 2.28.0