several changes, new stuff d6e0e6e9
Anselm R. Garbe · 2006-07-11 18:53 7 file(s) · +34 −19
bar.c +13 −11
5 5
6 6
#include "wm.h"
7 7
8 -
static const char *status[] = {
9 -
	"sh", "-c", "echo -n `date` `uptime | sed 's/.*://; s/,//g'`"
10 -
		" `acpi | awk '{print $4}' | sed 's/,//'`", 0 \
11 -
};
12 -
13 8
void
14 9
draw_bar()
15 10
{
16 -
	static char buf[1024];
17 -
18 -
	buf[0] = 0;
19 -
	pipe_spawn(buf, sizeof(buf), dpy, (char **)status);
20 -
21 11
	brush.rect = barrect;
22 12
	brush.rect.x = brush.rect.y = 0;
23 -
	draw(dpy, &brush, False, buf);
13 +
	draw(dpy, &brush, False, NULL);
14 +
15 +
	if(stack) {
16 +
		brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font);
17 +
		swap((void **)&brush.fg, (void **)&brush.bg);
18 +
		draw(dpy, &brush, False, stack->name);
19 +
		swap((void **)&brush.fg, (void **)&brush.bg);
20 +
		brush.rect.x += brush.rect.width;
21 +
	}
22 +
23 +
	brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font);
24 +
	brush.rect.x = barrect.x + barrect.width - brush.rect.width;
25 +
	draw(dpy, &brush, False, statustext);
24 26
25 27
	XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width,
26 28
			barrect.height, 0, 0);
client.c +5 −0
35 35
		}
36 36
	}
37 37
	XFree(name.value);
38 +
	if(c == stack)
39 +
		draw_bar();
40 +
	else
41 +
		draw_client(c);
38 42
}
39 43
40 44
void
66 70
	c->r[RFloat].height = wa->height;
67 71
	c->border = wa->border_width;
68 72
	XSetWindowBorderWidth(dpy, c->win, 0);
73 +
	XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
69 74
	XGetTransientForHint(dpy, c->win, &c->trans);
70 75
	if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
71 76
		c->size.flags = PSize;
config.h +1 −1
7 7
#define BGCOLOR		"#000000"
8 8
#define FGCOLOR		"#ffaa00"
9 9
#define BORDERCOLOR	"#000000"
10 -
#define STATUSDELAY 1 /* milliseconds */
10 +
#define STATUSDELAY	10 /* milliseconds */
event.c +0 −1
187 187
		}
188 188
		if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
189 189
			update_name(c);
190 -
			/*draw_frame(c->sel);*/
191 190
		}
192 191
	}
193 192
}
util.c +1 −1
134 134
			n += l;
135 135
		}
136 136
		close(pfd[0]);
137 -
		buf[n - 1] = 0;
137 +
		buf[n < len ? n : len - 1] = 0;
138 138
	}
139 139
	wait(0);
140 140
}
wm.c +12 −4
27 27
Bool running = True;
28 28
Bool sel_screen;
29 29
30 -
char *bartext, tag[256];
30 +
char statustext[1024], tag[256];
31 31
int screen;
32 32
33 33
Brush brush = {0};
35 35
Client *stack = NULL;
36 36
37 37
static Bool other_wm_running;
38 -
static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
38 +
static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
39 39
static int (*x_error_handler) (Display *, XErrorEvent *);
40 +
41 +
static const char *status[] = {
42 +
	"sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`" 
43 +
	" `uptime | sed 's/.*://; s/,//g'`"
44 +
	" `acpi | awk '{print $4}' | sed 's/,//'`", 0
45 +
};
40 46
41 47
static void
42 48
usage()
258 264
			barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
259 265
			CopyFromParent, DefaultVisual(dpy, screen),
260 266
			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
261 -
	bartext = NULL;
262 267
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
263 268
	XMapRaised(dpy, barwin);
269 +
	pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
264 270
	draw_bar();
265 271
266 272
	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
282 288
		t = timeout;
283 289
		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
284 290
			continue;
285 -
		else if(errno != EINTR)
291 +
		else if(errno != EINTR) {
292 +
			pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
286 293
			draw_bar();
294 +
		}
287 295
	}
288 296
289 297
	cleanup();
wm.h +2 −1
55 55
extern void (*handler[LASTEvent]) (XEvent *);
56 56
57 57
extern int screen;
58 -
extern char *bartext, tag[256];
58 +
extern char statustext[1024], tag[256];
59 59
60 60
extern Brush brush;
61 61
extern Client *clients, *stack;
74 74
extern Client *getclient(Window w);
75 75
extern void focus(Client *c);
76 76
extern void update_name(Client *c);
77 +
extern void draw_client(Client *c);
77 78
78 79
/* event.c */
79 80
extern unsigned int flush_events(long even_mask);