dwm-meillo

changeset 32:082c75b937b5

removed unnecessary crap
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:30:55 +0200
parents 386649deb651
children e90449e03167
files Makefile README client.c draw.c event.c kb.c util.c wm.c wm.h
diffstat 15 files changed, 94 insertions(+), 784 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Thu Jul 13 01:04:38 2006 +0200
     1.2 +++ b/Makefile	Thu Jul 13 01:30:55 2006 +0200
     1.3 @@ -3,14 +3,12 @@
     1.4  
     1.5  include config.mk
     1.6  
     1.7 -WMSRC = bar.c client.c draw.c event.c kb.c mouse.c util.c wm.c
     1.8 -WMOBJ = ${WMSRC:.c=.o}
     1.9 -MENSRC = menu.c draw.c util.c
    1.10 -MENOBJ = ${MENSRC:.c=.o}
    1.11 -MAN1 = gridwm.1 gridmenu.1
    1.12 -BIN = gridwm gridmenu
    1.13 +SRC = client.c draw.c event.c kb.c mouse.c util.c wm.c
    1.14 +OBJ = ${SRC:.c=.o}
    1.15 +MAN1 = gridwm.1 
    1.16 +BIN = gridwm
    1.17  
    1.18 -all: config gridwm gridmenu
    1.19 +all: config gridwm
    1.20  	@echo finished
    1.21  
    1.22  config:
    1.23 @@ -24,18 +22,14 @@
    1.24  	@echo CC $<
    1.25  	@${CC} -c ${CFLAGS} $<
    1.26  
    1.27 -${WMOBJ}: wm.h draw.h config.h util.h
    1.28 +${OBJ}: wm.h
    1.29  
    1.30 -gridmenu: ${MENOBJ}
    1.31 +gridwm: ${OBJ}
    1.32  	@echo LD $@
    1.33 -	@${CC} -o $@ ${MENOBJ} ${LDFLAGS}
    1.34 -
    1.35 -gridwm: ${WMOBJ}
    1.36 -	@echo LD $@
    1.37 -	@${CC} -o $@ ${WMOBJ} ${LDFLAGS}
    1.38 +	@${CC} -o $@ ${OBJ} ${LDFLAGS}
    1.39  
    1.40  clean:
    1.41 -	rm -f gridwm gridmenu *.o core
    1.42 +	rm -f gridwm *.o core
    1.43  
    1.44  dist: clean
    1.45  	mkdir -p gridwm-${VERSION}
     2.1 --- a/README	Thu Jul 13 01:04:38 2006 +0200
     2.2 +++ b/README	Thu Jul 13 01:30:55 2006 +0200
     2.3 @@ -37,7 +37,5 @@
     2.4  
     2.5  Configuration
     2.6  -------------
     2.7 -The configuration of gridwm is done by customizing the config.h source file. To
     2.8 -customize the key bindings edit kb.c. To change the status output, edit the
     2.9 -status command definition in wm.c.
    2.10 -
    2.11 +The configuration of gridwm is done by customizing the wm.h source file. To
    2.12 +customize the key bindings edit kb.c.
     3.1 --- a/bar.c	Thu Jul 13 01:04:38 2006 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,41 +0,0 @@
     3.4 -/*
     3.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     3.6 - * See LICENSE file for license details.
     3.7 - */
     3.8 -
     3.9 -#include "wm.h"
    3.10 -
    3.11 -void
    3.12 -draw_bar()
    3.13 -{
    3.14 -	int i;
    3.15 -	brush.x = brush.y = 0;
    3.16 -	brush.w = bw;
    3.17 -	brush.h = bh;
    3.18 -	draw(dpy, &brush, False, NULL);
    3.19 -
    3.20 -	brush.w = 0;
    3.21 -	for(i = 0; i < TLast; i++) {
    3.22 -		brush.x += brush.w;
    3.23 -		brush.w = textw(&brush.font, tags[i]) + bh;
    3.24 -		if(i == tsel) {
    3.25 -			swap((void **)&brush.fg, (void **)&brush.bg);
    3.26 -			draw(dpy, &brush, True, tags[i]);
    3.27 -			swap((void **)&brush.fg, (void **)&brush.bg);
    3.28 -		}
    3.29 -		else
    3.30 -			draw(dpy, &brush, True, tags[i]);
    3.31 -	}
    3.32 -	if(stack) {
    3.33 -		swap((void **)&brush.fg, (void **)&brush.bg);
    3.34 -		brush.x += brush.w;
    3.35 -		brush.w = textw(&brush.font, stack->name) + bh;
    3.36 -		draw(dpy, &brush, True, stack->name);
    3.37 -		swap((void **)&brush.fg, (void **)&brush.bg);
    3.38 -	}
    3.39 -	brush.w = textw(&brush.font, stext) + bh;
    3.40 -	brush.x = bx + bw - brush.w;
    3.41 -	draw(dpy, &brush, False, stext);
    3.42 -	XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, bw, bh, 0, 0);
    3.43 -	XFlush(dpy);
    3.44 -}
     4.1 --- a/client.c	Thu Jul 13 01:04:38 2006 +0200
     4.2 +++ b/client.c	Thu Jul 13 01:30:55 2006 +0200
     4.3 @@ -7,8 +7,8 @@
     4.4  #include <stdlib.h>
     4.5  #include <string.h>
     4.6  #include <X11/Xatom.h>
     4.7 +#include <X11/Xutil.h>
     4.8  
     4.9 -#include "util.h"
    4.10  #include "wm.h"
    4.11  
    4.12  void (*arrange)(void *aux);
    4.13 @@ -19,9 +19,9 @@
    4.14  	if(!stack)
    4.15  		return;
    4.16  	stack->x = sx;
    4.17 -	stack->y = bh;
    4.18 +	stack->y = sy;
    4.19  	stack->w = sw - 2 * stack->border;
    4.20 -	stack->h = sh - bh - 2 * stack->border;
    4.21 +	stack->h = sh - 2 * stack->border;
    4.22  	resize(stack);
    4.23  	discard_events(EnterWindowMask);
    4.24  }
    4.25 @@ -59,11 +59,11 @@
    4.26  		cols = rows;
    4.27  
    4.28  	gw = (sw - 2)  / cols;
    4.29 -	gh = (sh - bh - 2) / rows;
    4.30 +	gh = (sh - 2) / rows;
    4.31  
    4.32  	for(i = j = 0, c = clients; c; c = c->next) {
    4.33  		c->x = i * gw;
    4.34 -		c->y = j * gh + bh;
    4.35 +		c->y = j * gh;
    4.36  		c->w = gw;
    4.37  		c->h = gh;
    4.38  		resize(c);
    4.39 @@ -89,12 +89,12 @@
    4.40  		for(c = stack; c && c->snext; c = c->snext);
    4.41  	if(!c)
    4.42  		c = stack;
    4.43 -	raise(c);
    4.44 +	craise(c);
    4.45  	focus(c);
    4.46  }
    4.47  
    4.48  void
    4.49 -kill(void *aux)
    4.50 +ckill(void *aux)
    4.51  {
    4.52  	Client *c = stack;
    4.53  
    4.54 @@ -114,8 +114,8 @@
    4.55  	c->tw = 0;
    4.56  	for(i = 0; i < TLast; i++)
    4.57  		if(c->tags[i])
    4.58 -			c->tw += textw(&brush.font, c->tags[i]) + bh;
    4.59 -	c->tw += textw(&brush.font, c->name) + bh;
    4.60 +			c->tw += textw(&brush.font, c->tags[i]) + brush.font.height;
    4.61 +	c->tw += textw(&brush.font, c->name) + brush.font.height;
    4.62  	if(c->tw > c->w)
    4.63  		c->tw = c->w + 2;
    4.64  	c->tx = c->x + c->w - c->tw + 2;
    4.65 @@ -190,7 +190,7 @@
    4.66  }
    4.67  
    4.68  void
    4.69 -raise(Client *c)
    4.70 +craise(Client *c)
    4.71  {
    4.72  	XRaiseWindow(dpy, c->win);
    4.73  	XRaiseWindow(dpy, c->title);
    4.74 @@ -234,11 +234,9 @@
    4.75  	c->win = w;
    4.76  	c->tx = c->x = wa->x;
    4.77  	c->ty = c->y = wa->y;
    4.78 -	if(c->y < bh)
    4.79 -		c->ty = c->y += bh;
    4.80  	c->tw = c->w = wa->width;
    4.81  	c->h = wa->height;
    4.82 -	c->th = bh;
    4.83 +	c->th = th;
    4.84  	c->border = 1;
    4.85  	update_size(c);
    4.86  	XSetWindowBorderWidth(dpy, c->win, 1);
    4.87 @@ -379,10 +377,8 @@
    4.88  	XDestroyWindow(dpy, c->title);
    4.89  
    4.90  	for(l=&clients; *l && *l != c; l=&(*l)->next);
    4.91 -	eassert(*l == c);
    4.92  	*l = c->next;
    4.93  	for(l=&stack; *l && *l != c; l=&(*l)->snext);
    4.94 -	eassert(*l == c);
    4.95  	*l = c->snext;
    4.96  	free(c);
    4.97  
    4.98 @@ -418,10 +414,8 @@
    4.99  draw_client(Client *c)
   4.100  {
   4.101  	int i;
   4.102 -	if(c == stack) {
   4.103 -		draw_bar();
   4.104 +	if(c == stack)
   4.105  		return;
   4.106 -	}
   4.107  
   4.108  	brush.x = brush.y = 0;
   4.109  	brush.h = c->th;
   4.110 @@ -430,12 +424,12 @@
   4.111  	for(i = 0; i < TLast; i++) {
   4.112  		if(c->tags[i]) {
   4.113  			brush.x += brush.w;
   4.114 -			brush.w = textw(&brush.font, c->tags[i]) + bh;
   4.115 +			brush.w = textw(&brush.font, c->tags[i]) + brush.font.height;
   4.116  			draw(dpy, &brush, True, c->tags[i]);
   4.117  		}
   4.118  	}
   4.119  	brush.x += brush.w;
   4.120 -	brush.w = textw(&brush.font, c->name) + bh;
   4.121 +	brush.w = textw(&brush.font, c->name) + brush.font.height;
   4.122  	draw(dpy, &brush, True, c->name);
   4.123  	XCopyArea(dpy, brush.drawable, c->title, brush.gc,
   4.124  			0, 0, c->tw, c->th, 0, 0);
     5.1 --- a/config.h	Thu Jul 13 01:04:38 2006 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,15 +0,0 @@
     5.4 -/*
     5.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     5.6 - * See LICENSE file for license details.
     5.7 - */
     5.8 -
     5.9 -#define FONT		"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
    5.10 -#define BGCOLOR		"#666699"
    5.11 -#define FGCOLOR		"#ffffff"
    5.12 -#define BORDERCOLOR	"#9999CC"
    5.13 -#define STATUSDELAY	10 /* seconds */
    5.14 -
    5.15 -/* tags, see wm.c for further config */
    5.16 -enum { Tscratch, Tdev, Tirc, Twww, Twork, /* never remove: */ TLast };
    5.17 -
    5.18 -/* see kb.c for shortcut customization */
     6.1 --- a/draw.c	Thu Jul 13 01:04:38 2006 +0200
     6.2 +++ b/draw.c	Thu Jul 13 01:30:55 2006 +0200
     6.3 @@ -6,8 +6,9 @@
     6.4  #include <stdio.h>
     6.5  #include <string.h>
     6.6  
     6.7 -#include "draw.h"
     6.8 -#include "util.h"
     6.9 +#include <X11/Xlocale.h>
    6.10 +
    6.11 +#include "wm.h"
    6.12  
    6.13  static void
    6.14  drawborder(Display *dpy, Brush *b)
     7.1 --- a/draw.h	Thu Jul 13 01:04:38 2006 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,36 +0,0 @@
     7.4 -/*
     7.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     7.6 - * See LICENSE file for license details.
     7.7 - */
     7.8 -
     7.9 -#include <X11/Xlib.h>
    7.10 -#include <X11/Xlocale.h>
    7.11 -
    7.12 -typedef struct Brush Brush;
    7.13 -typedef struct Fnt Fnt;
    7.14 -
    7.15 -struct Fnt {
    7.16 -	XFontStruct *xfont;
    7.17 -	XFontSet set;
    7.18 -	int ascent;
    7.19 -	int descent;
    7.20 -	int height;
    7.21 -};
    7.22 -
    7.23 -struct Brush {
    7.24 -	GC gc;
    7.25 -	Drawable drawable;
    7.26 -	int x, y, w, h;
    7.27 -	Fnt font;
    7.28 -	unsigned long bg;
    7.29 -	unsigned long fg;
    7.30 -	unsigned long border;
    7.31 -};
    7.32 -
    7.33 -extern void draw(Display *dpy, Brush *b, Bool border, const char *text);
    7.34 -extern void loadcolors(Display *dpy, int screen, Brush *b,
    7.35 -		const char *bg, const char *fg, const char *bo);
    7.36 -extern void loadfont(Display *dpy, Fnt *font, const char *fontstr);
    7.37 -extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
    7.38 -extern unsigned int textw(Fnt *font, char *text);
    7.39 -extern unsigned int texth(Fnt *font);
     8.1 --- a/event.c	Thu Jul 13 01:04:38 2006 +0200
     8.2 +++ b/event.c	Thu Jul 13 01:30:55 2006 +0200
     8.3 @@ -51,7 +51,7 @@
     8.4  	Client *c;
     8.5  
     8.6  	if((c = getclient(ev->window))) {
     8.7 -		raise(c);
     8.8 +		craise(c);
     8.9  		switch(ev->button) {
    8.10  		default:
    8.11  			break;
    8.12 @@ -147,8 +147,6 @@
    8.13  	if(ev->count == 0) {
    8.14  		if((c = gettitle(ev->window)))
    8.15  			draw_client(c);
    8.16 -		else if(ev->window == barwin)
    8.17 -			draw_bar();
    8.18  	}
    8.19  }
    8.20  
    8.21 @@ -203,10 +201,7 @@
    8.22  		}
    8.23  		if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
    8.24  			update_name(c);
    8.25 -			if(c == stack)
    8.26 -				draw_bar();
    8.27 -			else
    8.28 -				draw_client(c);
    8.29 +			draw_client(c);
    8.30  		}
    8.31  	}
    8.32  }
     9.1 --- a/gridmenu.1	Thu Jul 13 01:04:38 2006 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,68 +0,0 @@
     9.4 -.TH GRIDMENU 1 grid-0.0
     9.5 -.SH NAME
     9.6 -gridmenu \- grid window manager menu
     9.7 -.SH SYNOPSIS
     9.8 -.B gridmenu
     9.9 -.RB [ \-v ]
    9.10 -.RB [ \-t
    9.11 -.IR title ]
    9.12 -.SH DESCRIPTION
    9.13 -.SS Overview
    9.14 -.B gridmenu
    9.15 -is a generic, highly customizable, and efficient menu for the X Window System,
    9.16 -originally designed for
    9.17 -.BR grid (1).
    9.18 -It supports arbitrary, user defined menu contents.
    9.19 -.SS Options
    9.20 -.TP
    9.21 -.B \-v
    9.22 -prints version information to stdout, then exits.
    9.23 -.TP
    9.24 -.BI \-t " title"
    9.25 -displays
    9.26 -.I title
    9.27 -above the menu.
    9.28 -.SS Usage
    9.29 -.B gridmenu
    9.30 -reads a list of newline-separated items from stdin and creates a menu.
    9.31 -When the user selects an item or enters any text and presses Enter, his choice
    9.32 -is printed to stdout and
    9.33 -.B gridmenu
    9.34 -terminates.
    9.35 -.SS Keyboard Control 
    9.36 -.B gridmenu
    9.37 -is completely controlled by the keyboard.  The following keys are recognized:
    9.38 -.TP 2
    9.39 -Any printable character
    9.40 -appends the character to the text in the input field. This works as a filter:
    9.41 -only items containing this text will be displayed.
    9.42 -.TP 2
    9.43 -Left/Right (Control-p/Control-n)
    9.44 -select the previous/next item.
    9.45 -.TP 2
    9.46 -Tab (Control-i)
    9.47 -copy the selected item to the input field.
    9.48 -.TP 2
    9.49 -Enter (Control-j)
    9.50 -confirm selection and quit (print the selected item to stdout).
    9.51 -.TP 2
    9.52 -Shift-Enter (Shift-Control-j)
    9.53 -confirm selection and quit (print the text in the input field to stdout).
    9.54 -.TP 2
    9.55 -Escape (Control-[)
    9.56 -quit without selecting an item.
    9.57 -.TP 2
    9.58 -Backspace (Control-h)
    9.59 -remove enough characters from the input field to change its filtering effect.
    9.60 -.TP 2
    9.61 -Control-u
    9.62 -remove all characters from the input field.
    9.63 -.SS Exit codes
    9.64 -.B gridmenu
    9.65 -returns
    9.66 -.B 0
    9.67 -if Enter is pressed on termination,
    9.68 -.B 1
    9.69 -if Escape is pressed.
    9.70 -.SH SEE ALSO
    9.71 -.BR gridwm (1)
    10.1 --- a/kb.c	Thu Jul 13 01:04:38 2006 +0200
    10.2 +++ b/kb.c	Thu Jul 13 01:30:55 2006 +0200
    10.3 @@ -9,25 +9,19 @@
    10.4  
    10.5  /********** CUSTOMIZE **********/
    10.6  
    10.7 -char *cmdterm[] = { 
    10.8 +char *term[] = { 
    10.9  	"aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
   10.10  	"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
   10.11  };
   10.12  
   10.13 -char *cmdproglist[] = {
   10.14 -		"sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null "
   10.15 -		"| awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
   10.16 -};
   10.17 -
   10.18  static Key key[] = {
   10.19 -	{ Mod1Mask, XK_Return, run, cmdterm },
   10.20 -	{ Mod1Mask, XK_p, run, cmdproglist}, 
   10.21 +	{ Mod1Mask, XK_Return, run, term },
   10.22  	{ Mod1Mask, XK_k, sel, "prev" }, 
   10.23  	{ Mod1Mask, XK_j, sel, "next" }, 
   10.24  	{ Mod1Mask, XK_g, grid, NULL }, 
   10.25  	{ Mod1Mask, XK_f, floating, NULL }, 
   10.26  	{ Mod1Mask, XK_m, max, NULL }, 
   10.27 -	{ Mod1Mask | ShiftMask, XK_c, kill, NULL }, 
   10.28 +	{ Mod1Mask | ShiftMask, XK_c, ckill, NULL }, 
   10.29  	{ Mod1Mask | ShiftMask, XK_q, quit, NULL },
   10.30  };
   10.31  
    11.1 --- a/menu.c	Thu Jul 13 01:04:38 2006 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,432 +0,0 @@
    11.4 -/*
    11.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
    11.6 - * (C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com>
    11.7 - * See LICENSE file for license details.
    11.8 - */
    11.9 -
   11.10 -#include "config.h"
   11.11 -#include "draw.h"
   11.12 -#include "util.h"
   11.13 -
   11.14 -#include <ctype.h>
   11.15 -#include <stdlib.h>
   11.16 -#include <stdio.h>
   11.17 -#include <string.h>
   11.18 -#include <unistd.h>
   11.19 -#include <X11/cursorfont.h>
   11.20 -#include <X11/Xutil.h>
   11.21 -#include <X11/keysym.h>
   11.22 -
   11.23 -typedef struct Item Item;
   11.24 -
   11.25 -struct Item {
   11.26 -	Item *next;		/* traverses all items */
   11.27 -	Item *left, *right;	/* traverses items matching current search pattern */
   11.28 -	char *text;
   11.29 -};
   11.30 -
   11.31 -static Display *dpy;
   11.32 -static Window root;
   11.33 -static Window win;
   11.34 -static Bool done = False;
   11.35 -
   11.36 -static Item *allitem = NULL;	/* first of all items */
   11.37 -static Item *item = NULL;	/* first of pattern matching items */
   11.38 -static Item *sel = NULL;
   11.39 -static Item *nextoff = NULL;
   11.40 -static Item *prevoff = NULL;
   11.41 -static Item *curroff = NULL;
   11.42 -
   11.43 -static int screen, mx, my, mw, mh;
   11.44 -static char *title = NULL;
   11.45 -static char text[4096];
   11.46 -static int ret = 0;
   11.47 -static int nitem = 0;
   11.48 -static unsigned int cmdw = 0;
   11.49 -static unsigned int tw = 0;
   11.50 -static unsigned int cw = 0;
   11.51 -static const int seek = 30;		/* 30px */
   11.52 -
   11.53 -static Brush brush = {0};
   11.54 -
   11.55 -static void draw_menu();
   11.56 -static void kpress(XKeyEvent * e);
   11.57 -
   11.58 -static char version[] = "gridmenu - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
   11.59 -
   11.60 -static void
   11.61 -usage() { error("usage: gridmenu [-v] [-t <title>]\n"); }
   11.62 -
   11.63 -static void
   11.64 -update_offsets()
   11.65 -{
   11.66 -	unsigned int tw, w = cmdw + 2 * seek;
   11.67 -
   11.68 -	if(!curroff)
   11.69 -		return;
   11.70 -
   11.71 -	for(nextoff = curroff; nextoff; nextoff=nextoff->right) {
   11.72 -		tw = textw(&brush.font, nextoff->text);
   11.73 -		if(tw > mw / 3)
   11.74 -			tw = mw / 3;
   11.75 -		w += tw + brush.font.height;
   11.76 -		if(w > mw)
   11.77 -			break;
   11.78 -	}
   11.79 -
   11.80 -	w = cmdw + 2 * seek;
   11.81 -	for(prevoff = curroff; prevoff && prevoff->left; prevoff=prevoff->left) {
   11.82 -		tw = textw(&brush.font, prevoff->left->text);
   11.83 -		if(tw > mw / 3)
   11.84 -			tw = mw / 3;
   11.85 -		w += tw + brush.font.height;
   11.86 -		if(w > mw)
   11.87 -			break;
   11.88 -	}
   11.89 -}
   11.90 -
   11.91 -static void
   11.92 -update_items(char *pattern)
   11.93 -{
   11.94 -	unsigned int plen = strlen(pattern);
   11.95 -	Item *i, *j;
   11.96 -
   11.97 -	if(!pattern)
   11.98 -		return;
   11.99 -
  11.100 -	if(!title || *pattern)
  11.101 -		cmdw = cw;
  11.102 -	else
  11.103 -		cmdw = tw;
  11.104 -
  11.105 -	item = j = NULL;
  11.106 -	nitem = 0;
  11.107 -
  11.108 -	for(i = allitem; i; i=i->next)
  11.109 -		if(!plen || !strncmp(pattern, i->text, plen)) {
  11.110 -			if(!j)
  11.111 -				item = i;
  11.112 -			else
  11.113 -				j->right = i;
  11.114 -			i->left = j;
  11.115 -			i->right = NULL;
  11.116 -			j = i;
  11.117 -			nitem++;
  11.118 -		}
  11.119 -	for(i = allitem; i; i=i->next)
  11.120 -		if(plen && strncmp(pattern, i->text, plen)
  11.121 -				&& strstr(i->text, pattern)) {
  11.122 -			if(!j)
  11.123 -				item = i;
  11.124 -			else
  11.125 -				j->right = i;
  11.126 -			i->left = j;
  11.127 -			i->right = NULL;
  11.128 -			j = i;
  11.129 -			nitem++;
  11.130 -		}
  11.131 -
  11.132 -	curroff = prevoff = nextoff = sel = item;
  11.133 -
  11.134 -	update_offsets();
  11.135 -}
  11.136 -
  11.137 -/* creates brush structs for brush mode drawing */
  11.138 -static void
  11.139 -draw_menu()
  11.140 -{
  11.141 -	Item *i;
  11.142 -
  11.143 -	brush.x = 0;
  11.144 -	brush.y = 0;
  11.145 -	brush.w = mw;
  11.146 -	brush.h = mh;
  11.147 -	draw(dpy, &brush, False, 0);
  11.148 -
  11.149 -	/* print command */
  11.150 -	if(!title || text[0]) {
  11.151 -		cmdw = cw;
  11.152 -		if(cmdw && item)
  11.153 -			brush.w = cmdw;
  11.154 -		draw(dpy, &brush, False, text);
  11.155 -	}
  11.156 -	else {
  11.157 -		cmdw = tw;
  11.158 -		brush.w = cmdw;
  11.159 -		draw(dpy, &brush, False, title);
  11.160 -	}
  11.161 -	brush.x += brush.w;
  11.162 -
  11.163 -	if(curroff) {
  11.164 -		brush.w = seek;
  11.165 -		draw(dpy, &brush, False, (curroff && curroff->left) ? "<" : 0);
  11.166 -		brush.x += brush.w;
  11.167 -
  11.168 -		/* determine maximum items */
  11.169 -		for(i = curroff; i != nextoff; i=i->right) {
  11.170 -			brush.border = False;
  11.171 -			brush.w = textw(&brush.font, i->text);
  11.172 -			if(brush.w > mw / 3)
  11.173 -				brush.w = mw / 3;
  11.174 -			brush.w += brush.font.height;
  11.175 -			if(sel == i) {
  11.176 -				swap((void **)&brush.fg, (void **)&brush.bg);
  11.177 -				draw(dpy, &brush, True, i->text);
  11.178 -				swap((void **)&brush.fg, (void **)&brush.bg);
  11.179 -			}
  11.180 -			else
  11.181 -				draw(dpy, &brush, False, i->text);
  11.182 -			brush.x += brush.w;
  11.183 -		}
  11.184 -
  11.185 -		brush.x = mw - seek;
  11.186 -		brush.w = seek;
  11.187 -		draw(dpy, &brush, False, nextoff ? ">" : 0);
  11.188 -	}
  11.189 -	XCopyArea(dpy, brush.drawable, win, brush.gc, 0, 0, mw, mh, 0, 0);
  11.190 -	XFlush(dpy);
  11.191 -}
  11.192 -
  11.193 -static void
  11.194 -kpress(XKeyEvent * e)
  11.195 -{
  11.196 -	KeySym ksym;
  11.197 -	char buf[32];
  11.198 -	int num, prev_nitem;
  11.199 -	unsigned int i, len = strlen(text);
  11.200 -
  11.201 -	buf[0] = 0;
  11.202 -	num = XLookupString(e, buf, sizeof(buf), &ksym, 0);
  11.203 -
  11.204 -	if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
  11.205 -			|| IsMiscFunctionKey(ksym) || IsPFKey(ksym)
  11.206 -			|| IsPrivateKeypadKey(ksym))
  11.207 -		return;
  11.208 -
  11.209 -	/* first check if a control mask is omitted */
  11.210 -	if(e->state & ControlMask) {
  11.211 -		switch (ksym) {
  11.212 -		default:	/* ignore other control sequences */
  11.213 -			return;
  11.214 -			break;
  11.215 -		case XK_h:
  11.216 -			ksym = XK_BackSpace;
  11.217 -			break;
  11.218 -		case XK_U:
  11.219 -		case XK_u:
  11.220 -			text[0] = 0;
  11.221 -			update_items(text);
  11.222 -			draw_menu();
  11.223 -			return;
  11.224 -			break;
  11.225 -		case XK_bracketleft:
  11.226 -			ksym = XK_Escape;
  11.227 -			break;
  11.228 -		}
  11.229 -	}
  11.230 -	switch(ksym) {
  11.231 -	case XK_Left:
  11.232 -		if(!(sel && sel->left))
  11.233 -			return;
  11.234 -		sel=sel->left;
  11.235 -		if(sel->right == curroff) {
  11.236 -			curroff = prevoff;
  11.237 -			update_offsets();
  11.238 -		}
  11.239 -		break;
  11.240 -	case XK_Tab:
  11.241 -		if(!sel)
  11.242 -			return;
  11.243 -		strncpy(text, sel->text, sizeof(text));
  11.244 -		update_items(text);
  11.245 -		break;
  11.246 -	case XK_Right:
  11.247 -		if(!(sel && sel->right))
  11.248 -			return;
  11.249 -		sel=sel->right;
  11.250 -		if(sel == nextoff) {
  11.251 -			curroff = nextoff;
  11.252 -			update_offsets();
  11.253 -		}
  11.254 -		break;
  11.255 -	case XK_Return:
  11.256 -		if(e->state & ShiftMask) {
  11.257 -			if(text)
  11.258 -				fprintf(stdout, "%s", text);
  11.259 -		}
  11.260 -		else if(sel)
  11.261 -			fprintf(stdout, "%s", sel->text);
  11.262 -		else if(text)
  11.263 -			fprintf(stdout, "%s", text);
  11.264 -		fflush(stdout);
  11.265 -		done = True;
  11.266 -		break;
  11.267 -	case XK_Escape:
  11.268 -		ret = 1;
  11.269 -		done = True;
  11.270 -		break;
  11.271 -	case XK_BackSpace:
  11.272 -		if((i = len)) {
  11.273 -			prev_nitem = nitem;
  11.274 -			do {
  11.275 -				text[--i] = 0;
  11.276 -				update_items(text);
  11.277 -			} while(i && nitem && prev_nitem == nitem);
  11.278 -			update_items(text);
  11.279 -		}
  11.280 -		break;
  11.281 -	default:
  11.282 -		if(num && !iscntrl((int) buf[0])) {
  11.283 -			buf[num] = 0;
  11.284 -			if(len > 0)
  11.285 -				strncat(text, buf, sizeof(text));
  11.286 -			else
  11.287 -				strncpy(text, buf, sizeof(text));
  11.288 -			update_items(text);
  11.289 -		}
  11.290 -	}
  11.291 -	draw_menu();
  11.292 -}
  11.293 -
  11.294 -static char *
  11.295 -read_allitems()
  11.296 -{
  11.297 -	static char *maxname = NULL;
  11.298 -	char *p, buf[1024];
  11.299 -	unsigned int len = 0, max = 0;
  11.300 -	Item *i, *new;
  11.301 -
  11.302 -	i = 0;
  11.303 -	while(fgets(buf, sizeof(buf), stdin)) {
  11.304 -		len = strlen(buf);
  11.305 -		if (buf[len - 1] == '\n')
  11.306 -			buf[len - 1] = 0;
  11.307 -		p = estrdup(buf);
  11.308 -		if(max < len) {
  11.309 -			maxname = p;
  11.310 -			max = len;
  11.311 -		}
  11.312 -
  11.313 -		new = emalloc(sizeof(Item));
  11.314 -		new->next = new->left = new->right = NULL;
  11.315 -		new->text = p;
  11.316 -		if(!i)
  11.317 -			allitem = new;
  11.318 -		else 
  11.319 -			i->next = new;
  11.320 -		i = new;
  11.321 -	}
  11.322 -
  11.323 -	return maxname;
  11.324 -}
  11.325 -
  11.326 -int
  11.327 -main(int argc, char *argv[])
  11.328 -{
  11.329 -	int i;
  11.330 -	XSetWindowAttributes wa;
  11.331 -	char *maxname;
  11.332 -	XEvent ev;
  11.333 -
  11.334 -	/* command line args */
  11.335 -	for(i = 1; i < argc; i++) {
  11.336 -		if (argv[i][0] == '-')
  11.337 -			switch (argv[i][1]) {
  11.338 -			case 'v':
  11.339 -				fprintf(stdout, "%s", version);
  11.340 -				exit(0);
  11.341 -				break;
  11.342 -			case 't':
  11.343 -				if(++i < argc)
  11.344 -					title = argv[i];
  11.345 -				else
  11.346 -					usage();
  11.347 -				break;
  11.348 -			default:
  11.349 -				usage();
  11.350 -				break;
  11.351 -			}
  11.352 -		else
  11.353 -			usage();
  11.354 -	}
  11.355 -
  11.356 -	dpy = XOpenDisplay(0);
  11.357 -	if(!dpy)
  11.358 -		error("gridmenu: cannot open dpy\n");
  11.359 -	screen = DefaultScreen(dpy);
  11.360 -	root = RootWindow(dpy, screen);
  11.361 -
  11.362 -	maxname = read_allitems();
  11.363 -
  11.364 -	/* grab as early as possible, but after reading all items!!! */
  11.365 -	while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
  11.366 -			 GrabModeAsync, CurrentTime) != GrabSuccess)
  11.367 -		usleep(1000);
  11.368 -
  11.369 -	/* style */
  11.370 -	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
  11.371 -	loadfont(dpy, &brush.font, FONT);
  11.372 -
  11.373 -	wa.override_redirect = 1;
  11.374 -	wa.background_pixmap = ParentRelative;
  11.375 -	wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
  11.376 -
  11.377 -	mx = my = 0;
  11.378 -	mw = DisplayWidth(dpy, screen);
  11.379 -	mh = texth(&brush.font);
  11.380 -
  11.381 -	win = XCreateWindow(dpy, root, mx, my, mw, mh, 0,
  11.382 -			DefaultDepth(dpy, screen), CopyFromParent,
  11.383 -			DefaultVisual(dpy, screen),
  11.384 -			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
  11.385 -	XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
  11.386 -	XFlush(dpy);
  11.387 -
  11.388 -	/* pixmap */
  11.389 -	brush.gc = XCreateGC(dpy, root, 0, 0);
  11.390 -	brush.drawable = XCreatePixmap(dpy, win, mw, mh,
  11.391 -			DefaultDepth(dpy, screen));
  11.392 -	XFlush(dpy);
  11.393 -
  11.394 -	if(maxname)
  11.395 -		cw = textw(&brush.font, maxname) + brush.font.height;
  11.396 -	if(cw > mw / 3)
  11.397 -		cw = mw / 3;
  11.398 -
  11.399 -	if(title) {
  11.400 -		tw = textw(&brush.font, title) + brush.font.height;
  11.401 -		if(tw > mw / 3)
  11.402 -			tw = mw / 3;
  11.403 -	}
  11.404 -
  11.405 -	cmdw = title ? tw : cw;
  11.406 -
  11.407 -	text[0] = 0;
  11.408 -	update_items(text);
  11.409 -	XMapRaised(dpy, win);
  11.410 -	draw_menu();
  11.411 -	XFlush(dpy);
  11.412 -
  11.413 -	/* main event loop */
  11.414 -	while(!done && !XNextEvent(dpy, &ev)) {
  11.415 -		switch (ev.type) {
  11.416 -		case KeyPress:
  11.417 -			kpress(&ev.xkey);
  11.418 -			break;
  11.419 -		case Expose:
  11.420 -			if(ev.xexpose.count == 0)
  11.421 -				draw_menu();
  11.422 -			break;
  11.423 -		default:
  11.424 -			break;
  11.425 -		}
  11.426 -	}
  11.427 -
  11.428 -	XUngrabKeyboard(dpy, CurrentTime);
  11.429 -	XFreePixmap(dpy, brush.drawable);
  11.430 -	XFreeGC(dpy, brush.gc);
  11.431 -	XDestroyWindow(dpy, win);
  11.432 -	XCloseDisplay(dpy);
  11.433 -
  11.434 -	return ret;
  11.435 -}
    12.1 --- a/util.c	Thu Jul 13 01:04:38 2006 +0200
    12.2 +++ b/util.c	Thu Jul 13 01:30:55 2006 +0200
    12.3 @@ -11,7 +11,7 @@
    12.4  #include <sys/wait.h>
    12.5  #include <unistd.h>
    12.6  
    12.7 -#include "util.h"
    12.8 +#include "wm.h"
    12.9  
   12.10  void
   12.11  error(char *errstr, ...) {
   12.12 @@ -60,20 +60,13 @@
   12.13  char *
   12.14  estrdup(const char *str)
   12.15  {
   12.16 -	void *res = strdup(str);
   12.17 +	char *res = strdup(str);
   12.18  	if(!res)
   12.19  		bad_malloc(strlen(str));
   12.20  	return res;
   12.21  }
   12.22  
   12.23  void
   12.24 -failed_assert(char *a, char *file, int line)
   12.25 -{
   12.26 -	fprintf(stderr, "Assertion \"%s\" failed at %s:%d\n", a, file, line);
   12.27 -	abort();
   12.28 -}
   12.29 -
   12.30 -void
   12.31  swap(void **p1, void **p2)
   12.32  {
   12.33  	void *tmp = *p1;
   12.34 @@ -99,43 +92,3 @@
   12.35  	}
   12.36  	wait(0);
   12.37  }
   12.38 -
   12.39 -void
   12.40 -pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[])
   12.41 -{
   12.42 -	unsigned int l, n;
   12.43 -	int pfd[2];
   12.44 -
   12.45 -	if(!argv || !argv[0])
   12.46 -		return;
   12.47 -
   12.48 -	if(pipe(pfd) == -1) {
   12.49 -		perror("pipe");
   12.50 -		exit(1);
   12.51 -	}
   12.52 -
   12.53 -	if(fork() == 0) {
   12.54 -		if(dpy)
   12.55 -			close(ConnectionNumber(dpy));
   12.56 -		setsid();
   12.57 -		dup2(pfd[1], STDOUT_FILENO);
   12.58 -		close(pfd[0]);
   12.59 -		close(pfd[1]);
   12.60 -		execvp(argv[0], argv);
   12.61 -		fprintf(stderr, "gridwm: execvp %s", argv[0]);
   12.62 -		perror(" failed");
   12.63 -	}
   12.64 -	else {
   12.65 -		l = n = 0;
   12.66 -		close(pfd[1]);
   12.67 -		while(n < len) {
   12.68 -			if((l = read(pfd[0], buf + n, len - n)) < 1)
   12.69 -				break;
   12.70 -			n += l;
   12.71 -		}
   12.72 -		while(l > n);
   12.73 -		close(pfd[0]);
   12.74 -		buf[n < len ? n : len - 1] = 0;
   12.75 -	}
   12.76 -	wait(0);
   12.77 -}
    13.1 --- a/util.h	Thu Jul 13 01:04:38 2006 +0200
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,22 +0,0 @@
    13.4 -/*
    13.5 - * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
    13.6 - * See LICENSE file for license details.
    13.7 - */
    13.8 -#include <X11/Xlib.h>
    13.9 -
   13.10 -extern void error(char *errstr, ...);
   13.11 -extern void *emallocz(unsigned int size);
   13.12 -extern void *emalloc(unsigned int size);
   13.13 -extern void *erealloc(void *ptr, unsigned int size);
   13.14 -extern char *estrdup(const char *str);
   13.15 -#define eassert(a) \
   13.16 -	do { \
   13.17 -		if(!(a)) \
   13.18 -			failed_assert(#a, __FILE__, __LINE__); \
   13.19 -	} while (0)
   13.20 -extern void failed_assert(char *a, char *file, int line);
   13.21 -extern void pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[]);
   13.22 -extern void spawn(Display *dpy, char *argv[]);
   13.23 -extern void swap(void **p1, void **p2);
   13.24 -extern unsigned int tokenize(char **result, unsigned int reslen,
   13.25 -		char *str, char delim);
    14.1 --- a/wm.c	Thu Jul 13 01:04:38 2006 +0200
    14.2 +++ b/wm.c	Thu Jul 13 01:30:55 2006 +0200
    14.3 @@ -3,15 +3,10 @@
    14.4   * See LICENSE file for license details.
    14.5   */
    14.6  
    14.7 -#include <errno.h>
    14.8 -
    14.9  #include <stdarg.h>
   14.10  #include <stdio.h>
   14.11  #include <stdlib.h>
   14.12  
   14.13 -#include <sys/types.h>
   14.14 -#include <sys/time.h>
   14.15 -
   14.16  #include <X11/cursorfont.h>
   14.17  #include <X11/Xatom.h>
   14.18  #include <X11/Xproto.h>
   14.19 @@ -28,17 +23,6 @@
   14.20  	[Twork] = "work",
   14.21  };
   14.22  
   14.23 -/* commands */
   14.24 -static char *cmdwallpaper[] = {
   14.25 -	"feh", "--bg-scale", "/home/garbeam/wallpaper/bg.jpg", NULL
   14.26 -};
   14.27 -
   14.28 -static char *cmdstatus[] = {
   14.29 -	"sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" 
   14.30 -	" `uptime | sed 's/.*://; s/,//g'`"
   14.31 -	" `acpi | awk '{print $4}' | sed 's/,//'`", NULL
   14.32 -};
   14.33 -
   14.34  /********** CUSTOMIZE **********/
   14.35  
   14.36  /* X structs */
   14.37 @@ -51,7 +35,7 @@
   14.38  
   14.39  char stext[1024];
   14.40  int tsel = Tdev; /* default tag */
   14.41 -int screen, sx, sy, sw, sh, bx, by, bw, bh;
   14.42 +int screen, sx, sy, sw, sh, th;
   14.43  
   14.44  Brush brush = {0};
   14.45  Client *clients = NULL;
   14.46 @@ -209,11 +193,6 @@
   14.47  	unsigned int mask;
   14.48  	Window w;
   14.49  	XEvent ev;
   14.50 -	fd_set fds;
   14.51 -	struct timeval t, timeout = {
   14.52 -		.tv_usec = 0,
   14.53 -		.tv_sec = STATUSDELAY,
   14.54 -	};
   14.55  
   14.56  	/* command line args */
   14.57  	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
   14.58 @@ -245,7 +224,6 @@
   14.59  	if(other_wm_running)
   14.60  		error("gridwm: another window manager is already running\n");
   14.61  
   14.62 -	spawn(dpy, cmdwallpaper);
   14.63  	sx = sy = 0;
   14.64  	sw = DisplayWidth(dpy, screen);
   14.65  	sh = DisplayHeight(dpy, screen);
   14.66 @@ -275,25 +253,11 @@
   14.67  	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
   14.68  	loadfont(dpy, &brush.font, FONT);
   14.69  
   14.70 -	wa.override_redirect = 1;
   14.71 -	wa.background_pixmap = ParentRelative;
   14.72 -	wa.event_mask = ExposureMask;
   14.73 +	th = texth(&brush.font);
   14.74  
   14.75 -	bx = by = 0;
   14.76 -	bw = sw;
   14.77 -	bh = texth(&brush.font);
   14.78 -	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
   14.79 -			CopyFromParent, DefaultVisual(dpy, screen),
   14.80 -			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
   14.81 -	XDefineCursor(dpy, barwin, cursor[CurNormal]);
   14.82 -	XMapRaised(dpy, barwin);
   14.83 -
   14.84 -	brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
   14.85 +	brush.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
   14.86  	brush.gc = XCreateGC(dpy, root, 0, 0);
   14.87  
   14.88 -	pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
   14.89 -	draw_bar();
   14.90 -
   14.91  	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
   14.92  					| LeaveWindowMask;
   14.93  	wa.cursor = cursor[CurNormal];
   14.94 @@ -303,21 +267,9 @@
   14.95  	scan_wins();
   14.96  
   14.97  	while(running) {
   14.98 -		if(XPending(dpy) > 0) {
   14.99 -			XNextEvent(dpy, &ev);
  14.100 -			if(handler[ev.type])
  14.101 -				(handler[ev.type]) (&ev); /* call handler */
  14.102 -			continue;
  14.103 -		}
  14.104 -		FD_ZERO(&fds);
  14.105 -		FD_SET(ConnectionNumber(dpy), &fds);
  14.106 -		t = timeout;
  14.107 -		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
  14.108 -			continue;
  14.109 -		else if(errno != EINTR) {
  14.110 -			pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
  14.111 -			draw_bar();
  14.112 -		}
  14.113 +		XNextEvent(dpy, &ev);
  14.114 +		if(handler[ev.type])
  14.115 +			(handler[ev.type])(&ev); /* call handler */
  14.116  	}
  14.117  
  14.118  	cleanup();
    15.1 --- a/wm.h	Thu Jul 13 01:04:38 2006 +0200
    15.2 +++ b/wm.h	Thu Jul 13 01:30:55 2006 +0200
    15.3 @@ -3,15 +3,25 @@
    15.4   * See LICENSE file for license details.
    15.5   */
    15.6  
    15.7 -#include "config.h"
    15.8 -#include "draw.h"
    15.9 -#include "util.h"
   15.10 +#include <X11/Xlib.h>
   15.11  
   15.12 -#include <X11/Xutil.h>
   15.13 +/********** CUSTOMIZE **********/
   15.14  
   15.15 +#define FONT		"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
   15.16 +#define BGCOLOR		"#666699"
   15.17 +#define FGCOLOR		"#ffffff"
   15.18 +#define BORDERCOLOR	"#9999CC"
   15.19 +#define STATUSDELAY	10 /* seconds */
   15.20  #define WM_PROTOCOL_DELWIN 1
   15.21  
   15.22 +/* tags */
   15.23 +enum { Tscratch, Tdev, Tirc, Twww, Twork, TLast };
   15.24 +
   15.25 +/********** CUSTOMIZE **********/
   15.26 +
   15.27 +typedef struct Brush Brush;
   15.28  typedef struct Client Client;
   15.29 +typedef struct Fnt Fnt;
   15.30  typedef struct Key Key;
   15.31  
   15.32  /* atoms */
   15.33 @@ -21,6 +31,24 @@
   15.34  /* cursor */
   15.35  enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
   15.36  
   15.37 +struct Fnt {
   15.38 +	XFontStruct *xfont;
   15.39 +	XFontSet set;
   15.40 +	int ascent;
   15.41 +	int descent;
   15.42 +	int height;
   15.43 +};
   15.44 +
   15.45 +struct Brush {
   15.46 +	GC gc;
   15.47 +	Drawable drawable;
   15.48 +	int x, y, w, h;
   15.49 +	Fnt font;
   15.50 +	unsigned long bg;
   15.51 +	unsigned long fg;
   15.52 +	unsigned long border;
   15.53 +};
   15.54 +
   15.55  struct Client {
   15.56  	char name[256];
   15.57  	char *tags[TLast];
   15.58 @@ -46,21 +74,27 @@
   15.59  };
   15.60  
   15.61  extern Display *dpy;
   15.62 -extern Window root, barwin;
   15.63 +extern Window root;
   15.64  extern Atom wm_atom[WMLast], net_atom[NetLast];
   15.65  extern Cursor cursor[CurLast];
   15.66  extern Bool running, issel;
   15.67  extern void (*handler[LASTEvent]) (XEvent *);
   15.68  extern void (*arrange)(void *aux);
   15.69  
   15.70 -extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh;
   15.71 +extern int tsel, screen, sx, sy, sw, sh, th;
   15.72  extern char stext[1024], *tags[TLast];
   15.73  
   15.74  extern Brush brush;
   15.75  extern Client *clients, *stack;
   15.76  
   15.77 -/* bar.c */
   15.78 -extern void draw_bar();
   15.79 +/* draw.c */
   15.80 +extern void draw(Display *dpy, Brush *b, Bool border, const char *text);
   15.81 +extern void loadcolors(Display *dpy, int screen, Brush *b,
   15.82 +		const char *bg, const char *fg, const char *bo);
   15.83 +extern void loadfont(Display *dpy, Fnt *font, const char *fontstr);
   15.84 +extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
   15.85 +extern unsigned int textw(Fnt *font, char *text);
   15.86 +extern unsigned int texth(Fnt *font);
   15.87  
   15.88  /* client.c */
   15.89  extern void manage(Window w, XWindowAttributes *wa);
   15.90 @@ -72,9 +106,9 @@
   15.91  extern void resize(Client *c);
   15.92  extern void update_size(Client *c);
   15.93  extern Client *gettitle(Window w);
   15.94 -extern void raise(Client *c);
   15.95 +extern void craise(Client *c);
   15.96  extern void lower(Client *c);
   15.97 -extern void kill(void *aux);
   15.98 +extern void ckill(void *aux);
   15.99  extern void sel(void *aux);
  15.100  extern void max(void *aux);
  15.101  extern void floating(void *aux);
  15.102 @@ -92,6 +126,15 @@
  15.103  extern void mresize(Client *c);
  15.104  extern void mmove(Client *c);
  15.105  
  15.106 +/* util.c */
  15.107 +extern void error(char *errstr, ...);
  15.108 +extern void *emallocz(unsigned int size);
  15.109 +extern void *emalloc(unsigned int size);
  15.110 +extern void *erealloc(void *ptr, unsigned int size);
  15.111 +extern char *estrdup(const char *str);
  15.112 +extern void spawn(Display *dpy, char *argv[]);
  15.113 +extern void swap(void **p1, void **p2);
  15.114 +
  15.115  /* wm.c */
  15.116  extern int error_handler(Display *dpy, XErrorEvent *error);
  15.117  extern void send_message(Window w, Atom a, long value);