My build of dwm
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.
 
 
 
 
 

235 lines
8.3 KiB

  1. diff -r 2bcd25cce4ab config.def.h
  2. --- a/config.def.h Sun Sep 27 20:20:14 2009 +0100
  3. +++ b/config.def.h Mon Oct 05 22:01:49 2009 -0300
  4. @@ -1,13 +1,16 @@
  5. /* See LICENSE file for copyright and license details. */
  6. /* appearance */
  7. +#define NUMCOLORS 4 // need at least 3
  8. +static const char colors[NUMCOLORS][ColLast][8] = {
  9. + // border foreground background
  10. + { "#cccccc", "#000000", "#cccccc" }, // 0 = normal
  11. + { "#0066ff", "#ffffff", "#0066ff" }, // 1 = selected
  12. + { "#0066ff", "#0066ff", "#ffffff" }, // 2 = urgent/warning
  13. + { "#ff0000", "#ffffff", "#ff0000" }, // 3 = error
  14. + // add more here
  15. +};
  16. static const char font[] = "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*";
  17. -static const char normbordercolor[] = "#cccccc";
  18. -static const char normbgcolor[] = "#cccccc";
  19. -static const char normfgcolor[] = "#000000";
  20. -static const char selbordercolor[] = "#0066ff";
  21. -static const char selbgcolor[] = "#0066ff";
  22. -static const char selfgcolor[] = "#ffffff";
  23. static const unsigned int borderpx = 1; /* border pixel of windows */
  24. static const unsigned int snap = 32; /* snap pixel */
  25. static const Bool showbar = True; /* False means no bar */
  26. @@ -45,7 +48,7 @@
  27. #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
  28. /* commands */
  29. -static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
  30. +static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", colors[0][ColBG], "-nf", colors[0][ColFG], "-sb", colors[1][ColBG], "-sf", colors[1][ColFG], NULL };
  31. static const char *termcmd[] = { "uxterm", NULL };
  32. static Key keys[] = {
  33. diff -r 2bcd25cce4ab dwm.c
  34. --- a/dwm.c Sun Sep 27 20:20:14 2009 +0100
  35. +++ b/dwm.c Mon Oct 05 22:01:49 2009 -0300
  36. @@ -48,6 +48,7 @@
  37. #define LENGTH(X) (sizeof X / sizeof X[0])
  38. #define MAX(A, B) ((A) > (B) ? (A) : (B))
  39. #define MIN(A, B) ((A) < (B) ? (A) : (B))
  40. +#define MAXCOLORS 8
  41. #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  42. #define WIDTH(X) ((X)->w + 2 * (X)->bw)
  43. #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
  44. @@ -95,8 +96,7 @@
  45. typedef struct {
  46. int x, y, w, h;
  47. - unsigned long norm[ColLast];
  48. - unsigned long sel[ColLast];
  49. + unsigned long colors[MAXCOLORS][ColLast];
  50. Drawable drawable;
  51. GC gc;
  52. struct {
  53. @@ -172,8 +172,9 @@
  54. static Monitor *dirtomon(int dir);
  55. static void drawbar(Monitor *m);
  56. static void drawbars(void);
  57. -static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
  58. -static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
  59. +static void drawcoloredtext(char *text);
  60. +static void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
  61. +static void drawtext(const char *text, unsigned long col[ColLast], Bool pad);
  62. static void enternotify(XEvent *e);
  63. static void expose(XEvent *e);
  64. static void focus(Client *c);
  65. @@ -691,14 +692,13 @@
  66. dc.x = 0;
  67. for(i = 0; i < LENGTH(tags); i++) {
  68. dc.w = TEXTW(tags[i]);
  69. - col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
  70. - drawtext(tags[i], col, urg & 1 << i);
  71. - drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
  72. - occ & 1 << i, urg & 1 << i, col);
  73. + col = dc.colors[ (m->tagset[m->seltags] & 1 << i ? 1:(urg & 1 << i ? 2:0))];
  74. + drawtext(tags[i], col, True);
  75. + drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, col);
  76. dc.x += dc.w;
  77. }
  78. dc.w = blw = TEXTW(m->ltsymbol);
  79. - drawtext(m->ltsymbol, dc.norm, False);
  80. + drawtext(m->ltsymbol, dc.colors[0], True);
  81. dc.x += dc.w;
  82. x = dc.x;
  83. if(m == selmon) { /* status is only drawn on selected monitor */
  84. @@ -708,19 +708,19 @@
  85. dc.x = x;
  86. dc.w = m->ww - x;
  87. }
  88. - drawtext(stext, dc.norm, False);
  89. + drawcoloredtext(stext);
  90. }
  91. else
  92. dc.x = m->ww;
  93. if((dc.w = dc.x - x) > bh) {
  94. dc.x = x;
  95. if(m->sel) {
  96. - col = m == selmon ? dc.sel : dc.norm;
  97. - drawtext(m->sel->name, col, False);
  98. - drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
  99. + col = m == selmon ? dc.colors[1] : dc.colors[0];
  100. + drawtext(m->sel->name, col, True);
  101. + drawsquare(m->sel->isfixed, m->sel->isfloating, col);
  102. }
  103. else
  104. - drawtext(NULL, dc.norm, False);
  105. + drawtext(NULL, dc.colors[0], False);
  106. }
  107. XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
  108. XSync(dpy, False);
  109. @@ -735,12 +735,42 @@
  110. }
  111. void
  112. -drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
  113. +drawcoloredtext(char *text) {
  114. + Bool first=True;
  115. + char *buf = text, *ptr = buf, c = 1;
  116. + unsigned long *col = dc.colors[0];
  117. + int i, ox = dc.x;
  118. +
  119. + while( *ptr ) {
  120. + for( i = 0; *ptr < 0 || *ptr > NUMCOLORS; i++, ptr++);
  121. + if( !*ptr ) break;
  122. + c=*ptr;
  123. + *ptr=0;
  124. + if( i ) {
  125. + dc.w = selmon->ww - dc.x;
  126. + drawtext(buf, col, first);
  127. + dc.x += textnw(buf, i) + textnw(&c,1);
  128. + if( first ) dc.x += ( dc.font.ascent + dc.font.descent ) / 2;
  129. + first = False;
  130. + } else if( first ) {
  131. + ox = dc.x += textnw(&c,1);
  132. + }
  133. + *ptr = c;
  134. + col = dc.colors[ c-1 ];
  135. + buf = ++ptr;
  136. + }
  137. + if( !first ) dc.x-=(dc.font.ascent+dc.font.descent)/2;
  138. + drawtext(buf, col, True);
  139. + dc.x = ox;
  140. +}
  141. +
  142. +void
  143. +drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
  144. int x;
  145. XGCValues gcv;
  146. XRectangle r = { dc.x, dc.y, dc.w, dc.h };
  147. - gcv.foreground = col[invert ? ColBG : ColFG];
  148. + gcv.foreground = col[ ColFG ];
  149. XChangeGC(dpy, dc.gc, GCForeground, &gcv);
  150. x = (dc.font.ascent + dc.font.descent + 2) / 4;
  151. r.x = dc.x + 1;
  152. @@ -756,18 +786,18 @@
  153. }
  154. void
  155. -drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
  156. +drawtext(const char *text, unsigned long col[ColLast], Bool pad) {
  157. char buf[256];
  158. int i, x, y, h, len, olen;
  159. XRectangle r = { dc.x, dc.y, dc.w, dc.h };
  160. - XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
  161. + XSetForeground(dpy, dc.gc, col[ ColBG ]);
  162. XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
  163. if(!text)
  164. return;
  165. olen = strlen(text);
  166. - h = dc.font.ascent + dc.font.descent;
  167. - y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
  168. + h = pad ? (dc.font.ascent + dc.font.descent) : 0;
  169. + y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);
  170. x = dc.x + (h / 2);
  171. /* shorten text if necessary */
  172. for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
  173. @@ -776,7 +806,7 @@
  174. memcpy(buf, text, len);
  175. if(len < olen)
  176. for(i = len; i && i > len - 3; buf[--i] = '.');
  177. - XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
  178. + XSetForeground(dpy, dc.gc, col[ ColFG ]);
  179. if(dc.font.set)
  180. XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
  181. else
  182. @@ -824,7 +854,7 @@
  183. detachstack(c);
  184. attachstack(c);
  185. grabbuttons(c, True);
  186. - XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
  187. + XSetWindowBorder(dpy, c->win, dc.colors[1][ColBorder]);
  188. XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
  189. }
  190. else
  191. @@ -1132,7 +1162,7 @@
  192. }
  193. wc.border_width = c->bw;
  194. XConfigureWindow(dpy, w, CWBorderWidth, &wc);
  195. - XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
  196. + XSetWindowBorder(dpy, w, dc.colors[0][ColBorder]);
  197. configure(c); /* propagates border_width, if size doesn't change */
  198. updatesizehints(c);
  199. XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  200. @@ -1498,12 +1528,11 @@
  201. cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
  202. cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
  203. /* init appearance */
  204. - dc.norm[ColBorder] = getcolor(normbordercolor);
  205. - dc.norm[ColBG] = getcolor(normbgcolor);
  206. - dc.norm[ColFG] = getcolor(normfgcolor);
  207. - dc.sel[ColBorder] = getcolor(selbordercolor);
  208. - dc.sel[ColBG] = getcolor(selbgcolor);
  209. - dc.sel[ColFG] = getcolor(selfgcolor);
  210. + for(int i=0; i<NUMCOLORS; i++) {
  211. + dc.colors[i][ColBorder] = getcolor( colors[i][ColBorder] );
  212. + dc.colors[i][ColFG] = getcolor( colors[i][ColFG] );
  213. + dc.colors[i][ColBG] = getcolor( colors[i][ColBG] );
  214. + }
  215. dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
  216. dc.gc = XCreateGC(dpy, root, 0, NULL);
  217. XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
  218. @@ -1665,7 +1694,7 @@
  219. if(!c)
  220. return;
  221. grabbuttons(c, False);
  222. - XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
  223. + XSetWindowBorder(dpy, c->win, dc.colors[0][ColBorder]);
  224. XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  225. }