bar.c
author Anselm R. Garbe <garbeam@wmii.de>
Fri, 14 Jul 2006 17:43:56 +0200
changeset 66 50450aa24a46
parent 58 1269bd127551
child 71 7681ef838201
permissions -rw-r--r--
removed a bunch of lines through swap removal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     1
/*
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     2
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     3
 * See LICENSE file for license details.
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     4
 */
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     5
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     6
#include "dwm.h"
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     7
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
     8
void
58
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
     9
barclick(XButtonPressedEvent *e)
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    10
{
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    11
	int x = 0;
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    12
	Arg a;
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    13
	for(a.i = 0; a.i < TLast; a.i++) {
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    14
		x += textw(tags[a.i]) + dc.font.height;
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    15
		if(e->x < x) {
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    16
			view(&a);
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    17
			return;
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    18
		}
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    19
	}
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    20
}
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    21
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 57
diff changeset
    22
void
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    23
draw_bar()
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    24
{
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    25
	int i;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    26
	dc.x = dc.y = 0;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    27
	dc.w = bw;
66
50450aa24a46 removed a bunch of lines through swap removal
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
    28
	drawtext(NULL, False, False);
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    29
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    30
	dc.w = 0;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    31
	for(i = 0; i < TLast; i++) {
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    32
		dc.x += dc.w;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    33
		dc.w = textw(tags[i]) + dc.font.height;
66
50450aa24a46 removed a bunch of lines through swap removal
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
    34
		drawtext(tags[i], i == tsel, True);
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    35
	}
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    36
	if(sel) {
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    37
		dc.x += dc.w;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    38
		dc.w = textw(sel->name) + dc.font.height;
66
50450aa24a46 removed a bunch of lines through swap removal
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
    39
		drawtext(sel->name, True, True);
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    40
	}
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    41
	dc.w = textw(stext) + dc.font.height;
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    42
	dc.x = bx + bw - dc.w;
66
50450aa24a46 removed a bunch of lines through swap removal
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
    43
	drawtext(stext, False, False);
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    44
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    45
	XFlush(dpy);
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
    46
}