about summary refs log tree commit diff stats
path: root/bar.c
blob: 1f125122695214639acb1dfcaf171d681496926b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
 * See LICENSE file for license details.
 */

#include "wm.h"

void
draw_bar()
{
	brush.rect = barrect;
	brush.rect.x = brush.rect.y = 0;
	draw(dpy, &brush, False, NULL);

	if(stack) {
		brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font);
		swap((void **)&brush.fg, (void **)&brush.bg);
		draw(dpy, &brush, True, stack->name);
		swap((void **)&brush.fg, (void **)&brush.bg);
		brush.rect.x += brush.rect.width;
	}

	brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font);
	brush.rect.x = barrect.x + barrect.width - brush.rect.width;
	draw(dpy, &brush, False, statustext);

	XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width,
			barrect.height, 0, 0);
	XFlush(dpy);
}
> *res = realloc(ptr, size); if(!res) bad_malloc(size); return res; } char * estrdup(const char *str) { char *res = strdup(str); if(!res) bad_malloc(strlen(str)); return res; } void swap(void **p1, void **p2) { void *tmp = *p1; *p1 = *p2; *p2 = tmp; } void spawn(Display *dpy, char *argv[]) { if(!argv || !argv[0]) return; if(fork() == 0) { if(fork() == 0) { if(dpy) close(ConnectionNumber(dpy)); setsid(); execvp(argv[0], argv); fprintf(stderr, "gridwm: execvp %s", argv[0]); perror(" failed"); } exit (0); } wait(0); }