summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client.c22
-rw-r--r--config.arg.h5
-rw-r--r--draw.c96
-rw-r--r--dwm.18
-rw-r--r--dwm.h2
-rw-r--r--tag.c2
-rw-r--r--view.c8
7 files changed, 69 insertions, 74 deletions
diff --git a/client.c b/client.c
index af0190f..c18d88b 100644
--- a/client.c
+++ b/client.c
@@ -28,19 +28,15 @@ resizetitle(Client *c)
28{ 28{
29 int i; 29 int i;
30 30
31 c->tw = 0; 31 c->tw = textw(c->name);
32 for(i = 0; i < ntags; i++)
33 if(c->tags[i])
34 c->tw += textw(tags[i]);
35 c->tw += textw(c->name);
36 if(c->tw > c->w) 32 if(c->tw > c->w)
37 c->tw = c->w + 2; 33 c->tw = c->w + 2;
38 c->tx = c->x + c->w - c->tw + 2; 34 c->tx = c->x + c->w - c->tw + 2;
39 c->ty = c->y; 35 c->ty = c->y;
40 if(isvisible(c)) 36 if(isvisible(c))
41 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); 37 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
42 else 38 else
43 XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); 39 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
44 40
45} 41}
46 42
@@ -65,7 +61,7 @@ void
65ban(Client *c) 61ban(Client *c)
66{ 62{
67 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 63 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
68 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); 64 XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
69} 65}
70 66
71void 67void
@@ -106,7 +102,7 @@ getctitle(Window w)
106 Client *c; 102 Client *c;
107 103
108 for(c = clients; c; c = c->next) 104 for(c = clients; c; c = c->next)
109 if(c->title == w) 105 if(c->twin == w)
110 return c; 106 return c;
111 return NULL; 107 return NULL;
112} 108}
@@ -214,7 +210,7 @@ manage(Window w, XWindowAttributes *wa)
214 twa.background_pixmap = ParentRelative; 210 twa.background_pixmap = ParentRelative;
215 twa.event_mask = ExposureMask | EnterWindowMask; 211 twa.event_mask = ExposureMask | EnterWindowMask;
216 212
217 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 213 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
218 0, DefaultDepth(dpy, screen), CopyFromParent, 214 0, DefaultDepth(dpy, screen), CopyFromParent,
219 DefaultVisual(dpy, screen), 215 DefaultVisual(dpy, screen),
220 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 216 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
@@ -242,7 +238,7 @@ manage(Window w, XWindowAttributes *wa)
242 sel = c; 238 sel = c;
243 arrange(NULL); 239 arrange(NULL);
244 XMapWindow(dpy, c->win); 240 XMapWindow(dpy, c->win);
245 XMapWindow(dpy, c->title); 241 XMapWindow(dpy, c->twin);
246 if(isvisible(c)) 242 if(isvisible(c))
247 focus(c); 243 focus(c);
248} 244}
@@ -329,7 +325,7 @@ void
329settitle(Client *c) 325settitle(Client *c)
330{ 326{
331 char **list = NULL; 327 char **list = NULL;
332 int n; 328 int i, n;
333 XTextProperty name; 329 XTextProperty name;
334 330
335 name.nitems = 0; 331 name.nitems = 0;
@@ -392,7 +388,7 @@ unmanage(Client *c)
392 XSetErrorHandler(xerrordummy); 388 XSetErrorHandler(xerrordummy);
393 389
394 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 390 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
395 XDestroyWindow(dpy, c->title); 391 XDestroyWindow(dpy, c->twin);
396 392
397 if(c->prev) 393 if(c->prev)
398 c->prev->next = c->next; 394 c->prev->next = c->next;
diff --git a/config.arg.h b/config.arg.h
index 70c245f..0e6b480 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -7,8 +7,7 @@
7const char *tags[] = { "work", "net", "fnord", NULL }; 7const char *tags[] = { "work", "net", "fnord", NULL };
8 8
9#define DEFMODE dotile /* dofloat */ 9#define DEFMODE dotile /* dofloat */
10#define TFONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" 10#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
11#define FONT "-*-snap-*-*-*-*-*-*-*-*-*-*-*-*"
12#define BGCOLOR "#0d121d" 11#define BGCOLOR "#0d121d"
13#define FGCOLOR "#eeeeee" 12#define FGCOLOR "#eeeeee"
14#define BORDERCOLOR "#3f484d" 13#define BORDERCOLOR "#3f484d"
@@ -19,7 +18,7 @@ const char *tags[] = { "work", "net", "fnord", NULL };
19static Key key[] = { \ 18static Key key[] = { \
20 /* modifier key function arguments */ \ 19 /* modifier key function arguments */ \
21 { MODKEY|ShiftMask, XK_Return, spawn, \ 20 { MODKEY|ShiftMask, XK_Return, spawn, \
22 { .cmd = "exec uxterm +sb -bg black -fg '#eeeeee' -fn '"TFONT"'" } }, \ 21 { .cmd = "exec uxterm +sb -bg black -fg '#eeeeee' -fn '"FONT"'" } }, \
23 { MODKEY, XK_p, spawn, \ 22 { MODKEY, XK_p, spawn, \
24 { .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \ 23 { .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
25 "awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \ 24 "awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
diff --git a/draw.c b/draw.c
index 96780f0..cbf6502 100644
--- a/draw.c
+++ b/draw.c
@@ -22,19 +22,9 @@ textnw(const char *text, unsigned int len)
22} 22}
23 23
24static void 24static void
25drawtext(const char *text, Bool invert) 25drawborder()
26{ 26{
27 int x, y, w, h;
28 static char buf[256];
29 unsigned int len, olen;
30 XGCValues gcv;
31 XPoint points[5]; 27 XPoint points[5];
32 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
33
34 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
35 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
36 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
37 XSetForeground(dpy, dc.gc, dc.border);
38 points[0].x = dc.x; 28 points[0].x = dc.x;
39 points[0].y = dc.y; 29 points[0].y = dc.y;
40 points[1].x = dc.w - 1; 30 points[1].x = dc.w - 1;
@@ -46,6 +36,23 @@ drawtext(const char *text, Bool invert)
46 points[4].x = 0; 36 points[4].x = 0;
47 points[4].y = -(dc.h - 1); 37 points[4].y = -(dc.h - 1);
48 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); 38 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
39}
40
41static void
42drawtext(const char *text, Bool invert, Bool highlight)
43{
44 int x, y, w, h;
45 static char buf[256];
46 unsigned int len, olen;
47 DC tmp;
48 XGCValues gcv;
49 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
50
51 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
52 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
53 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
54 XSetForeground(dpy, dc.gc, dc.border);
55 drawborder();
49 56
50 if(!text) 57 if(!text)
51 return; 58 return;
@@ -75,18 +82,25 @@ drawtext(const char *text, Bool invert)
75 82
76 if(w > dc.w) 83 if(w > dc.w)
77 return; /* too long */ 84 return; /* too long */
78
79 gcv.foreground = invert ? dc.bg : dc.fg; 85 gcv.foreground = invert ? dc.bg : dc.fg;
80 gcv.background = invert ? dc.fg : dc.bg; 86 gcv.background = invert ? dc.fg : dc.bg;
81 if(dc.font.set) { 87 if(dc.font.set) {
82 XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); 88 XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
83 XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc, 89 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
84 x, y, buf, len);
85 } 90 }
86 else { 91 else {
87 gcv.font = dc.font.xfont->fid; 92 gcv.font = dc.font.xfont->fid;
88 XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); 93 XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
89 XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); 94 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
95 }
96 if(highlight) {
97 tmp = dc;
98 dc.x += 2;
99 dc.y += 2;
100 dc.w -= 4;
101 dc.h -= 4;
102 drawborder();
103 dc = tmp;
90 } 104 }
91} 105}
92 106
@@ -110,36 +124,29 @@ drawstatus()
110 124
111 dc.x = dc.y = 0; 125 dc.x = dc.y = 0;
112 dc.w = bw; 126 dc.w = bw;
113 drawtext(NULL, !istile); 127 drawtext(NULL, !istile, False);
114 128
115 dc.w = 0; 129 dc.w = 0;
116 for(i = 0; i < ntags; i++) { 130 for(i = 0; i < ntags; i++) {
117 dc.x += dc.w; 131 dc.x += dc.w;
118 dc.w = textw(tags[i]); 132 dc.w = textw(tags[i]);
119 if(istile) 133 if(istile)
120 drawtext(tags[i], seltag[i]); 134 drawtext(tags[i], seltag[i], sel && sel->tags[i]);
121 else 135 else
122 drawtext(tags[i], !seltag[i]); 136 drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
123 } 137 }
124 x = dc.x + dc.w; 138 x = dc.x + dc.w;
125 dc.w = textw(stext); 139 dc.w = textw(stext);
126 dc.x = bx + bw - dc.w; 140 dc.x = bx + bw - dc.w;
127 drawtext(stext, !istile); 141 if(dc.x < x) {
128 142 dc.x = x;
129 if(sel) { 143 dc.w = bw - x;
130 for(i = 0; i < ntags; i++) 144 }
131 if(sel->tags[i]) { 145 drawtext(stext, !istile, False);
132 dc.w = textw(tags[i]); 146
133 dc.x -= dc.w; 147 if(sel && ((dc.w = dc.x - x) > bh)) {
134 if(dc.x < x) 148 dc.x = x;
135 break; 149 drawtext(sel->name, istile, False);
136 drawtext(tags[i], istile);
137 }
138 if(dc.x > x && (dc.x - x) > bh) {
139 dc.w = dc.x - x;
140 dc.x = x;
141 drawtext(sel->name, istile);
142 }
143 } 150 }
144 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); 151 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
145 XSync(dpy, False); 152 XSync(dpy, False);
@@ -153,26 +160,17 @@ drawtitle(Client *c)
153 160
154 if(c == sel && issel) { 161 if(c == sel && issel) {
155 drawstatus(); 162 drawstatus();
156 XUnmapWindow(dpy, c->title); 163 XUnmapWindow(dpy, c->twin);
157 XSetWindowBorder(dpy, c->win, dc.fg); 164 XSetWindowBorder(dpy, c->win, dc.fg);
158 return; 165 return;
159 } 166 }
160 167
161 XSetWindowBorder(dpy, c->win, dc.bg); 168 XSetWindowBorder(dpy, c->win, dc.bg);
162 XMapWindow(dpy, c->title); 169 XMapWindow(dpy, c->twin);
163 170 dc.x = dc.y = 0;
164 dc.y = dc.w = 0; 171 dc.w = c->tw;
165 dc.x = c->tw; 172 drawtext(c->name, !istile, False);
166 for(i = 0; i < ntags; i++) 173 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
167 if(c->tags[i]) {
168 dc.w = textw(tags[i]);
169 dc.x -= dc.w;
170 drawtext(tags[i], !istile);
171 }
172 dc.w = dc.x;
173 dc.x = 0;
174 drawtext(c->name, !istile);
175 XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
176 XSync(dpy, False); 174 XSync(dpy, False);
177} 175}
178 176
diff --git a/dwm.1 b/dwm.1
index dd17bbc..a5056d3 100644
--- a/dwm.1
+++ b/dwm.1
@@ -21,12 +21,12 @@ tags. Selecting a certain tag for viewing will display all windows with that
21tag. 21tag.
22.P 22.P
23.B dwm 23.B dwm
24contains a small status bar which displays all available tags, the title and the 24contains a small status bar which displays all available tags, the title
25tags of the focused window, and the text read from standard input. 25of the focused window, and the text read from standard input. The tags of the
26focused window are highlighted.
26.P 27.P
27.B dwm draws a 1-pixel border around windows to indicate the focus state. 28.B dwm draws a 1-pixel border around windows to indicate the focus state.
28Unfocused windows contain a small bar in front of them displaying their title 29Unfocused windows contain a small bar in front of them displaying their title.
29and tags.
30.SH OPTIONS 30.SH OPTIONS
31.TP 31.TP
32.B \-v 32.B \-v
diff --git a/dwm.h b/dwm.h
index 4e9c6b5..9d2d959 100644
--- a/dwm.h
+++ b/dwm.h
@@ -60,7 +60,7 @@ struct Client {
60 Client *next; 60 Client *next;
61 Client *prev; 61 Client *prev;
62 Window win; 62 Window win;
63 Window title; 63 Window twin;
64}; 64};
65 65
66extern const char *tags[]; 66extern const char *tags[];
diff --git a/tag.c b/tag.c
index 3a32c52..a3dc6ab 100644
--- a/tag.c
+++ b/tag.c
@@ -141,4 +141,6 @@ toggletag(Arg *arg)
141 settitle(sel); 141 settitle(sel);
142 if(!isvisible(sel)) 142 if(!isvisible(sel))
143 arrange(NULL); 143 arrange(NULL);
144 else
145 drawstatus();
144} 146}
diff --git a/view.c b/view.c
index 22b1794..0108a23 100644
--- a/view.c
+++ b/view.c
@@ -168,21 +168,21 @@ restack()
168 fi = 0; 168 fi = 0;
169 mi = 2 * f; 169 mi = 2 * f;
170 if(sel->isfloat || arrange == dofloat) { 170 if(sel->isfloat || arrange == dofloat) {
171 wins[fi++] = sel->title; 171 wins[fi++] = sel->twin;
172 wins[fi++] = sel->win; 172 wins[fi++] = sel->win;
173 } 173 }
174 else { 174 else {
175 wins[mi++] = sel->title; 175 wins[mi++] = sel->twin;
176 wins[mi++] = sel->win; 176 wins[mi++] = sel->win;
177 } 177 }
178 for(c = clients; c; c = c->next) 178 for(c = clients; c; c = c->next)
179 if(isvisible(c) && c != sel) { 179 if(isvisible(c) && c != sel) {
180 if(c->isfloat || arrange == dofloat) { 180 if(c->isfloat || arrange == dofloat) {
181 wins[fi++] = c->title; 181 wins[fi++] = c->twin;
182 wins[fi++] = c->win; 182 wins[fi++] = c->win;
183 } 183 }
184 else { 184 else {
185 wins[mi++] = c->title; 185 wins[mi++] = c->twin;
186 wins[mi++] = c->win; 186 wins[mi++] = c->win;
187 } 187 }
188 } 188 }