about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--bar.c17
-rw-r--r--client.c64
-rw-r--r--cmd.c12
-rw-r--r--config.h8
-rw-r--r--draw.c45
-rw-r--r--draw.h8
-rw-r--r--event.c17
-rw-r--r--font.c81
-rw-r--r--menu.c97
-rw-r--r--mouse.c20
-rw-r--r--wm.c23
-rw-r--r--wm.h7
12 files changed, 164 insertions, 235 deletions
diff --git a/bar.c b/bar.c
index 1f12512..f70a246 100644
--- a/bar.c
+++ b/bar.c
@@ -8,23 +8,22 @@
 void
 draw_bar()
 {
-	brush.rect = barrect;
-	brush.rect.x = brush.rect.y = 0;
+	brush.x = brush.y = 0;
+	brush.w = bw;
+	brush.h = bh;
 	draw(dpy, &brush, False, NULL);
 
 	if(stack) {
-		brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font);
+		brush.w = textw(&brush.font, stack->name) + bh;
 		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.x += brush.w;
 	}
 
-	brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font);
-	brush.rect.x = barrect.x + barrect.width - brush.rect.width;
+	brush.w = textw(&brush.font, statustext) + bh;
+	brush.x = bx + bw - brush.w;
 	draw(dpy, &brush, False, statustext);
-
-	XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width,
-			barrect.height, 0, 0);
+	XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, bw, bh, 0, 0);
 	XFlush(dpy);
 }
diff --git a/client.c b/client.c
index ee659c4..84fbce5 100644
--- a/client.c
+++ b/client.c
@@ -10,7 +10,16 @@
 #include "util.h"
 #include "wm.h"
 
-#define CLIENT_MASK		(StructureNotifyMask | PropertyChangeMask | EnterWindowMask)
+static void
+resize_title(Client *c)
+{
+	c->tw = textw(&brush.font, c->name) + bh;
+	if(c->tw > c->w)
+		c->tw = c->w + 2;
+	c->tx = c->x + c->w - c->tw + 2;
+	c->ty = c->y;
+	XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
+}
 
 void
 update_name(Client *c)
@@ -37,6 +46,7 @@ update_name(Client *c)
 		}
 	}
 	XFree(name.value);
+	resize_title(c);
 }
 
 void
@@ -74,26 +84,37 @@ update_size(Client *c)
 }
 
 void
+raise(Client *c)
+{
+	XRaiseWindow(dpy, c->win);
+	XRaiseWindow(dpy, c->title);
+}
+
+void
+lower(Client *c)
+{
+	XLowerWindow(dpy, c->title);
+	XLowerWindow(dpy, c->win);
+}
+
+void
 focus(Client *c)
 {
 	Client **l, *old;
 
 	old = stack;
-	for(l=&stack; *l && *l != c; l=&(*l)->snext);
+	for(l = &stack; *l && *l != c; l = &(*l)->snext);
 	eassert(*l == c);
 	*l = c->snext;
 	c->snext = stack;
 	stack = c;
-	XRaiseWindow(dpy, c->win);
-	XRaiseWindow(dpy, c->title);
-	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
 	if(old && old != c) {
 		XMapWindow(dpy, old->title);
 		draw_client(old);
 	}
 	XUnmapWindow(dpy, c->title);
-	draw_bar();
-	discard_events(EnterWindowMask);
+	draw_client(old);
+	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
 	XFlush(dpy);
 }
 
@@ -107,13 +128,16 @@ manage(Window w, XWindowAttributes *wa)
 	c->win = w;
 	c->tx = c->x = wa->x;
 	c->ty = c->y = wa->y;
+	if(c->y < bh)
+		c->ty = c->y += bh;
 	c->tw = c->w = wa->width;
 	c->h = wa->height;
-	c->th = barrect.height;
+	c->th = bh;
 	update_size(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XSetWindowBorder(dpy, c->win, brush.border);
-	XSelectInput(dpy, c->win, CLIENT_MASK);
+	XSelectInput(dpy, c->win,
+			StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
 	XGetTransientForHint(dpy, c->win, &c->trans);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
@@ -130,8 +154,8 @@ manage(Window w, XWindowAttributes *wa)
 	*l = c;
 	c->snext = stack;
 	stack = c;
-	XMapWindow(dpy, c->win);
-	XMapWindow(dpy, c->title);
+	XMapRaised(dpy, c->win);
+	XMapRaised(dpy, c->title);
 	XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
 			GrabModeAsync, GrabModeSync, None, None);
 	XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
@@ -147,6 +171,7 @@ resize(Client *c)
 {
 	XConfigureEvent e;
 
+	resize_title(c);
 	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
 	e.type = ConfigureNotify;
 	e.event = c->win;
@@ -158,9 +183,7 @@ resize(Client *c)
 	e.border_width = 0;
 	e.above = None;
 	e.override_redirect = False;
-	XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
 	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
-	XSelectInput(dpy, c->win, CLIENT_MASK);
 	XFlush(dpy);
 }
 
@@ -219,17 +242,14 @@ getclient(Window w)
 void
 draw_client(Client *c)
 {
-	if(c == stack)
+	if(c == stack) {
 		draw_bar();
+		return;
+	}
 
-	c->tw = textwidth(&brush.font, c->name) + labelheight(&brush.font);
-	c->tx = c->x + c->w - c->tw + 2;
-	c->ty = c->y;
-	XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
-
-	brush.rect.x = brush.rect.y = 0;
-	brush.rect.width = c->tw;
-	brush.rect.height = c->th;
+	brush.x = brush.y = 0;
+	brush.w = c->tw;
+	brush.h = c->th;
 
 	draw(dpy, &brush, True, c->name);
 	XCopyArea(dpy, brush.drawable, c->title, brush.gc,
diff --git a/cmd.c b/cmd.c
index c14c3e6..baa3ae9 100644
--- a/cmd.c
+++ b/cmd.c
@@ -23,16 +23,18 @@ void
 sel(void *aux)
 {
 	const char *arg = aux;
-	Client *c;
+	Client *c = NULL;
 
 	if(!arg || !stack)
 		return;
 	if(!strncmp(arg, "next", 5))
-		focus(stack->snext ? stack->snext : stack);
-	else if(!strncmp(arg, "prev", 5)) {
+		c = stack->snext ? stack->snext : stack;
+	else if(!strncmp(arg, "prev", 5))
 		for(c = stack; c && c->snext; c = c->snext);
-		focus(c ? c : stack);
-	}
+	if(!c)
+		c = stack;
+	raise(c);
+	focus(c);
 }
 
 void
diff --git a/config.h b/config.h
index ec633c3..9d28e75 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
  */
 
 #define FONT		"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
-#define BGCOLOR		"#0c0c33"
-#define FGCOLOR		"#b2c8cd"
-#define BORDERCOLOR	"#3030c0"
-#define STATUSDELAY	10 /* milliseconds */
+#define BGCOLOR		"#666699"
+#define FGCOLOR		"#ffffff"
+#define BORDERCOLOR	"#9999CC"
+#define STATUSDELAY	10 /* seconds */
diff --git a/draw.c b/draw.c
index a3c526e..c148362 100644
--- a/draw.c
+++ b/draw.c
@@ -15,16 +15,16 @@ drawborder(Display *dpy, Brush *b)
 	XPoint points[5];
 	XSetLineAttributes(dpy, b->gc, 1, LineSolid, CapButt, JoinMiter);
 	XSetForeground(dpy, b->gc, b->border);
-	points[0].x = b->rect.x;
-	points[0].y = b->rect.y;
-	points[1].x = b->rect.width - 1;
+	points[0].x = b->x;
+	points[0].y = b->y;
+	points[1].x = b->w - 1;
 	points[1].y = 0;
 	points[2].x = 0;
-	points[2].y = b->rect.height - 1;
-	points[3].x = -(b->rect.width - 1);
+	points[2].y = b->h - 1;
+	points[3].x = -(b->w - 1);
 	points[3].y = 0;
 	points[4].x = 0;
-	points[4].y = -(b->rect.height - 1);
+	points[4].y = -(b->h - 1);
 	XDrawLines(dpy, b->drawable, b->gc, points, 5, CoordModePrevious);
 }
 
@@ -34,9 +34,10 @@ draw(Display *dpy, Brush *b, Bool border, const char *text)
 	unsigned int x, y, w, h, len;
 	static char buf[256];
 	XGCValues gcv;
+	XRectangle r = { b->x, b->y, b->w, b->h };
 
 	XSetForeground(dpy, b->gc, b->bg);
-	XFillRectangles(dpy, b->drawable, b->gc, &b->rect, 1);
+	XFillRectangles(dpy, b->drawable, b->gc, &r, 1);
 
 	if(border)
 		drawborder(dpy, b);
@@ -51,14 +52,14 @@ draw(Display *dpy, Brush *b, Bool border, const char *text)
 	buf[len] = 0;
 
 	h = b->font.ascent + b->font.descent;
-	y = b->rect.y + (b->rect.height / 2) - (h / 2) + b->font.ascent;
-	x = b->rect.x + (h / 2);
+	y = b->y + (b->h / 2) - (h / 2) + b->font.ascent;
+	x = b->x + (h / 2);
 
 	/* shorten text if necessary */
-	while(len && (w = textwidth_l(&b->font, buf, len)) > b->rect.width - h)
+	while(len && (w = textnw(&b->font, buf, len)) > b->w - h)
 		buf[--len] = 0;
 
-	if(w > b->rect.width)
+	if(w > b->w)
 		return; /* too long */
 
 	gcv.foreground = b->fg;
@@ -94,20 +95,26 @@ loadcolors(Display *dpy, int screen, Brush *b,
 }
 
 unsigned int
-textwidth_l(Fnt *font, char *text, unsigned int len)
+textnw(Fnt *font, char *text, unsigned int len)
 {
+	XRectangle r;
 	if(font->set) {
-		XRectangle r;
-		XmbTextExtents(font->set, text, len, 0, &r);
+		XmbTextExtents(font->set, text, len, NULL, &r);
 		return r.width;
 	}
 	return XTextWidth(font->xfont, text, len);
 }
 
 unsigned int
-textwidth(Fnt *font, char *text)
+textw(Fnt *font, char *text)
 {
-	return textwidth_l(font, text, strlen(text));
+	return textnw(font, text, strlen(text));
+}
+
+unsigned int
+texth(Fnt *font)
+{
+	return font->height + 4;
 }
 
 void
@@ -162,9 +169,3 @@ loadfont(Display *dpy, Fnt *font, const char *fontstr)
 	}
 	font->height = font->ascent + font->descent;
 }
-
-unsigned int
-labelheight(Fnt *font)
-{
-	return font->height + 4;
-}
diff --git a/draw.h b/draw.h
index 6c3d886..4cd6fb1 100644
--- a/draw.h
+++ b/draw.h
@@ -20,7 +20,7 @@ struct Fnt {
 struct Brush {
 	GC gc;
 	Drawable drawable;
-	XRectangle rect;
+	int x, y, w, h;
 	Fnt font;
 	unsigned long bg;
 	unsigned long fg;
@@ -31,6 +31,6 @@ extern void draw(Display *dpy, Brush *b, Bool border, const char *text);
 extern void loadcolors(Display *dpy, int screen, Brush *b,
 		const char *bg, const char *fg, const char *bo);
 extern void loadfont(Display *dpy, Fnt *font, const char *fontstr);
-extern unsigned int textwidth_l(Fnt *font, char *text, unsigned int len);
-extern unsigned int textwidth(Fnt *font, char *text);
-extern unsigned int labelheight(Fnt *font);
+extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
+extern unsigned int textw(Fnt *font, char *text);
+extern unsigned int texth(Fnt *font);
diff --git a/event.c b/event.c
index 604420d..1db3d96 100644
--- a/event.c
+++ b/event.c
@@ -37,13 +37,11 @@ void (*handler[LASTEvent]) (XEvent *) = {
 	[UnmapNotify] = unmapnotify
 };
 
-unsigned int
+void
 discard_events(long even_mask)
 {
 	XEvent ev;
-	unsigned int n = 0;
-	while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
-	return n;
+	while(XCheckMaskEvent(dpy, even_mask, &ev));
 }
 
 static void
@@ -53,6 +51,7 @@ buttonpress(XEvent *e)
 	Client *c;
 
 	if((c = getclient(ev->window))) {
+		raise(c);
 		switch(ev->button) {
 		default:
 			break;
@@ -60,7 +59,7 @@ buttonpress(XEvent *e)
 			mmove(c);
 			break;
 		case Button2:
-			XLowerWindow(dpy, c->win);
+			lower(c);
 			break;
 		case Button3:
 			mresize(c);
@@ -122,10 +121,8 @@ enternotify(XEvent *e)
 
 	if((c = getclient(ev->window)))
 		focus(c);
-	else if(ev->window == root) {
+	else if(ev->window == root)
 		sel_screen = True;
-		/*draw_frames();*/
-	}
 }
 
 static void
@@ -133,10 +130,8 @@ leavenotify(XEvent *e)
 {
 	XCrossingEvent *ev = &e->xcrossing;
 
-	if((ev->window == root) && !ev->same_screen) {
+	if((ev->window == root) && !ev->same_screen)
 		sel_screen = True;
-		/*draw_frames();*/
-	}
 }
 
 static void
diff --git a/font.c b/font.c
deleted file mode 100644
index a6b8225..0000000
--- a/font.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-
-unsigned int
-textwidth_l(BlitzFont *font, char *text, unsigned int len)
-{
-	if(font->set) {
-		XRectangle r;
-		XmbTextExtents(font->set, text, len, nil, &r);
-		return r.width;
-	}
-	return XTextWidth(font->xfont, text, len);
-}
-
-unsigned int
-textwidth(BlitzFont *font, char *text)
-{
-	return blitz_textwidth_l(font, text, strlen(text));
-}
-
-void
-loadfont(Blitz *blitz, BlitzFont *font)
-{
-	char *fontname = font->fontstr;
-	char **missing = nil, *def = "?";
-	int n;
-
-	setlocale(LC_ALL, "");
-	if(font->set)
-		XFreeFontSet(blitz->dpy, font->set);
-	font->set = XCreateFontSet(blitz->dpy, fontname, &missing, &n, &def);
-	if(missing) {
-		while(n--)
-			fprintf(stderr, "missing fontset: %s\n", missing[n]);
-		XFreeStringList(missing);
-		if(font->set) {
-			XFreeFontSet(blitz->dpy, font->set);
-			font->set = nil;
-		}
-	}
-	if(font->set) {
-		XFontSetExtents *font_extents;
-		XFontStruct **xfonts;
-		char **font_names;
-		unsigned int i;
-
-		font->ascent = font->descent = 0;
-		font_extents = XExtentsOfFontSet(font->set);
-		n = XFontsOfFontSet(font->set, &xfonts, &font_names);
-		for(i = 0, font->ascent = 0, font->descent = 0; i < n; i++) {
-			if(font->ascent < (*xfonts)->ascent)
-				font->ascent = (*xfonts)->ascent;
-			if(font->descent < (*xfonts)->descent)
-				font->descent = (*xfonts)->descent;
-			xfonts++;
-		}
-	}
-	else {
-		if(font->xfont)
-			XFreeFont(blitz->dpy, font->xfont);
-		font->xfont = nil;
-		font->xfont = XLoadQueryFont(blitz->dpy, fontname);
-		if (!font->xfont) {
-			fontname = "fixed";
-			font->xfont = XLoadQueryFont(blitz->dpy, fontname);
-		}
-		if (!font->xfont) {
-			fprintf(stderr, "%s", "error, cannot load 'fixed' font\n");
-			exit(1);
-		}
-		font->ascent = font->xfont->ascent;
-		font->descent = font->xfont->descent;
-	}
-}
diff --git a/menu.c b/menu.c
index e09d3b7..2392ed5 100644
--- a/menu.c
+++ b/menu.c
@@ -31,7 +31,6 @@ struct Item {
 static Display *dpy;
 static Window root;
 static Window win;
-static XRectangle rect;
 static Bool done = False;
 
 static Item *allitem = NULL;	/* first of all items */
@@ -41,14 +40,14 @@ static Item *nextoff = NULL;
 static Item *prevoff = NULL;
 static Item *curroff = NULL;
 
-static int screen;
+static int screen, mx, my, mw, mh;
 static char *title = NULL;
 static char text[4096];
 static int ret = 0;
 static int nitem = 0;
 static unsigned int cmdw = 0;
-static unsigned int twidth = 0;
-static unsigned int cwidth = 0;
+static unsigned int tw = 0;
+static unsigned int cw = 0;
 static const int seek = 30;		/* 30px */
 
 static Brush brush = {0};
@@ -74,21 +73,21 @@ update_offsets()
 		return;
 
 	for(nextoff = curroff; nextoff; nextoff=nextoff->right) {
-		tw = textwidth(&brush.font, nextoff->text);
-		if(tw > rect.width / 3)
-			tw = rect.width / 3;
+		tw = textw(&brush.font, nextoff->text);
+		if(tw > mw / 3)
+			tw = mw / 3;
 		w += tw + brush.font.height;
-		if(w > rect.width)
+		if(w > mw)
 			break;
 	}
 
 	w = cmdw + 2 * seek;
 	for(prevoff = curroff; prevoff && prevoff->left; prevoff=prevoff->left) {
-		tw = textwidth(&brush.font, prevoff->left->text);
-		if(tw > rect.width / 3)
-			tw = rect.width / 3;
+		tw = textw(&brush.font, prevoff->left->text);
+		if(tw > mw / 3)
+			tw = mw / 3;
 		w += tw + brush.font.height;
-		if(w > rect.width)
+		if(w > mw)
 			break;
 	}
 }
@@ -103,9 +102,9 @@ update_items(char *pattern)
 		return;
 
 	if(!title || *pattern)
-		cmdw = cwidth;
+		cmdw = cw;
 	else
-		cmdw = twidth;
+		cmdw = tw;
 
 	item = j = NULL;
 	nitem = 0;
@@ -143,42 +142,40 @@ update_items(char *pattern)
 static void
 draw_menu()
 {
-	unsigned int offx = 0;
 	Item *i;
 
-	brush.rect = rect;
-	brush.rect.x = 0;
-	brush.rect.y = 0;
+	brush.x = 0;
+	brush.y = 0;
+	brush.w = mw;
+	brush.h = mh;
 	draw(dpy, &brush, False, 0);
 
 	/* print command */
 	if(!title || text[0]) {
-		cmdw = cwidth;
+		cmdw = cw;
 		if(cmdw && item)
-			brush.rect.width = cmdw;
+			brush.w = cmdw;
 		draw(dpy, &brush, False, text);
 	}
 	else {
-		cmdw = twidth;
-		brush.rect.width = cmdw;
+		cmdw = tw;
+		brush.w = cmdw;
 		draw(dpy, &brush, False, title);
 	}
-	offx += brush.rect.width;
+	brush.x += brush.w;
 
 	if(curroff) {
-		brush.rect.x = offx;
-		brush.rect.width = seek;
-		offx += brush.rect.width;
+		brush.w = seek;
 		draw(dpy, &brush, False, (curroff && curroff->left) ? "<" : 0);
+		brush.x += brush.w;
 
 		/* determine maximum items */
 		for(i = curroff; i != nextoff; i=i->right) {
 			brush.border = False;
-			brush.rect.x = offx;
-			brush.rect.width = textwidth(&brush.font, i->text);
-			if(brush.rect.width > rect.width / 3)
-				brush.rect.width = rect.width / 3;
-			brush.rect.width += brush.font.height;
+			brush.w = textw(&brush.font, i->text);
+			if(brush.w > mw / 3)
+				brush.w = mw / 3;
+			brush.w += brush.font.height;
 			if(sel == i) {
 				swap((void **)&brush.fg, (void **)&brush.bg);
 				draw(dpy, &brush, True, i->text);
@@ -186,15 +183,14 @@ draw_menu()
 			}
 			else
 				draw(dpy, &brush, False, i->text);
-			offx += brush.rect.width;
+			brush.x += brush.w;
 		}
 
-		brush.rect.x = rect.width - seek;
-		brush.rect.width = seek;
+		brush.x = mw - seek;
+		brush.w = seek;
 		draw(dpy, &brush, False, nextoff ? ">" : 0);
 	}
-	XCopyArea(dpy, brush.drawable, win, brush.gc, 0, 0, rect.width,
-			rect.height, 0, 0);
+	XCopyArea(dpy, brush.drawable, win, brush.gc, 0, 0, mw, mh, 0, 0);
 	XFlush(dpy);
 }
 
@@ -399,36 +395,35 @@ main(int argc, char *argv[])
 	wa.background_pixmap = ParentRelative;
 	wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
 
-	rect.width = DisplayWidth(dpy, screen);
-	rect.height = labelheight(&brush.font);
-	rect.y = DisplayHeight(dpy, screen) - rect.height;
-	rect.x = 0;
+	mx = my = 0;
+	mw = DisplayWidth(dpy, screen);
+	mh = texth(&brush.font);
 
-	win = XCreateWindow(dpy, root, rect.x, rect.y,
-			rect.width, rect.height, 0, DefaultDepth(dpy, screen),
-			CopyFromParent, DefaultVisual(dpy, screen),
+	win = XCreateWindow(dpy, root, mx, my, mw, mh, 0,
+			DefaultDepth(dpy, screen), CopyFromParent,
+			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
 	XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
 	XFlush(dpy);
 
 	/* pixmap */
 	brush.gc = XCreateGC(dpy, root, 0, 0);
-	brush.drawable = XCreatePixmap(dpy, win, rect.width, rect.height,
+	brush.drawable = XCreatePixmap(dpy, win, mw, mh,
 			DefaultDepth(dpy, screen));
 	XFlush(dpy);
 
 	if(maxname)
-		cwidth = textwidth(&brush.font, maxname) + brush.font.height;
-	if(cwidth > rect.width / 3)
-		cwidth = rect.width / 3;
+		cw = textw(&brush.font, maxname) + brush.font.height;
+	if(cw > mw / 3)
+		cw = mw / 3;
 
 	if(title) {
-		twidth = textwidth(&brush.font, title) + brush.font.height;
-		if(twidth > rect.width / 3)
-			twidth = rect.width / 3;
+		tw = textw(&brush.font, title) + brush.font.height;
+		if(tw > mw / 3)
+			tw = mw / 3;
 	}
 
-	cmdw = title ? twidth : cwidth;
+	cmdw = title ? tw : cw;
 
 	text[0] = 0;
 	update_items(text);
diff --git a/mouse.c b/mouse.c
index 577f23c..896d6b0 100644
--- a/mouse.c
+++ b/mouse.c
@@ -45,21 +45,21 @@ mresize(Client *c)
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurResize], CurrentTime) != GrabSuccess)
 		return;
-	XGrabServer(dpy);
 	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
 	for(;;) {
-		XMaskEvent(dpy, MouseMask, &ev);
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
 		switch(ev.type) {
 		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
 		case MotionNotify:
-			XUngrabServer(dpy);
+			XFlush(dpy);
 			mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y);
 			XResizeWindow(dpy, c->win, c->w, c->h);
-			XGrabServer(dpy);
 			break;
 		case ButtonRelease:
 			resize(c);
-			XUngrabServer(dpy);
 			XUngrabPointer(dpy, CurrentTime);
 			return;
 		}
@@ -80,21 +80,21 @@ mmove(Client *c)
 				None, cursor[CurMove], CurrentTime) != GrabSuccess)
 		return;
 	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
-	XGrabServer(dpy);
 	for(;;) {
-		XMaskEvent(dpy, MouseMask, &ev);
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
 		switch (ev.type) {
 		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
 		case MotionNotify:
-			XUngrabServer(dpy);
+			XFlush(dpy);
 			c->x = old_cx + (ev.xmotion.x - x1);
 			c->y = old_cy + (ev.xmotion.y - y1);
 			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
-			XGrabServer(dpy);
 			break;
 		case ButtonRelease:
 			resize(c);
-			XUngrabServer(dpy);
 			XUngrabPointer(dpy, CurrentTime);
 			return;
 		}
diff --git a/wm.c b/wm.c
index 82b2dee..f0069d2 100644
--- a/wm.c
+++ b/wm.c
@@ -23,12 +23,11 @@ Display *dpy;
 Window root, barwin;
 Atom wm_atom[WMLast], net_atom[NetLast];
 Cursor cursor[CurLast];
-XRectangle rect, barrect;
 Bool running = True;
 Bool sel_screen;
 
 char statustext[1024], tag[256];
-int screen;
+int screen, sx, sy, sw, sh, bx, by, bw, bh;
 
 Brush brush = {0};
 Client *clients = NULL;
@@ -39,7 +38,7 @@ static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R.
 static int (*x_error_handler) (Display *, XErrorEvent *);
 
 static const char *status[] = {
-	"sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`" 
+	"sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" 
 	" `uptime | sed 's/.*://; s/,//g'`"
 	" `acpi | awk '{print $4}' | sed 's/,//'`", 0
 };
@@ -220,9 +219,9 @@ main(int argc, char *argv[])
 	if(other_wm_running)
 		error("gridwm: another window manager is already running\n");
 
-	rect.x = rect.y = 0;
-	rect.width = DisplayWidth(dpy, screen);
-	rect.height = DisplayHeight(dpy, screen);
+	sx = sy = 0;
+	sw = DisplayWidth(dpy, screen);
+	sh = DisplayHeight(dpy, screen);
 	sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
 
 	XSetErrorHandler(0);
@@ -253,18 +252,16 @@ main(int argc, char *argv[])
 	wa.background_pixmap = ParentRelative;
 	wa.event_mask = ExposureMask;
 
-	barrect = rect;
-	barrect.height = labelheight(&brush.font);
-	barrect.y = rect.height - barrect.height;
-	barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
-			barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
+	bx = by = 0;
+	bw = sw;
+	bh = texth(&brush.font);
+	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
 			CopyFromParent, DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
 	XMapRaised(dpy, barwin);
 
-	brush.drawable = XCreatePixmap(dpy, root, rect.width, barrect.height,
-			DefaultDepth(dpy, screen));
+	brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
 	brush.gc = XCreateGC(dpy, root, 0, 0);
 
 	pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
diff --git a/wm.h b/wm.h
index 8f31f60..b5b07b5 100644
--- a/wm.h
+++ b/wm.h
@@ -46,11 +46,10 @@ extern Display *dpy;
 extern Window root, barwin;
 extern Atom wm_atom[WMLast], net_atom[NetLast];
 extern Cursor cursor[CurLast];
-extern XRectangle rect, barrect;
 extern Bool running, sel_screen, grid;
 extern void (*handler[LASTEvent]) (XEvent *);
 
-extern int screen;
+extern int screen, sx, sy, sw, sh, bx, by, bw, bh;
 extern char statustext[1024], tag[256];
 
 extern Brush brush;
@@ -75,9 +74,11 @@ extern void draw_client(Client *c);
 extern void resize(Client *c);
 extern void update_size(Client *c);
 extern Client *gettitle(Window w);
+extern void raise(Client *c);
+extern void lower(Client *c);
 
 /* event.c */
-extern unsigned int discard_events(long even_mask);
+extern void discard_events(long even_mask);
 
 /* key.c */
 extern void update_keys();
-island.net> 1996-09-02 19:39:24 -0400 snapshot of project "lynx", label v2_6' href='/ingrix/lynx-snapshots/commit/src/LYDownload.c?id=e087f6d44e87f489fcb3056e86319ebba4218156'>e087f6d4
d7e8d7e4 ^
e087f6d4






57bfc74f ^












e087f6d4


5816641f ^
51a6f85e ^
e087f6d4



86b4d41a ^
e087f6d4





86b4d41a ^
e087f6d4



5816641f ^
2a94396c ^
5816641f ^





e087f6d4
5816641f ^
e087f6d4
2a94396c ^
e087f6d4
5816641f ^


e087f6d4
86b4d41a ^
64c4d93e ^
e087f6d4


57bfc74f ^


fb4db89a ^
e087f6d4


86b4d41a ^
e087f6d4
86b4d41a ^
e087f6d4


86b4d41a ^
e087f6d4
fb4db89a ^
86b4d41a ^
e087f6d4




fb4db89a ^
e087f6d4


fb4db89a ^
e087f6d4






57bfc74f ^


2a94396c ^

fb4db89a ^
e087f6d4










0eae931d ^
e087f6d4



2a94396c ^
e087f6d4

86b4d41a ^
e087f6d4
2a94396c ^
e087f6d4
2a94396c ^
57bfc74f ^
5816641f ^
57bfc74f ^
e087f6d4

86b4d41a ^


e087f6d4


b63d287c ^
e087f6d4
24efd81e ^

e087f6d4


57bfc74f ^


e087f6d4
57bfc74f ^
2a94396c ^
24efd81e ^


2a94396c ^
ee5cdfe9 ^
2a94396c ^
86b4d41a ^
5816641f ^
86b4d41a ^
b63d287c ^


e087f6d4






86b4d41a ^
e087f6d4
86b4d41a ^
e087f6d4





86b4d41a ^
e087f6d4
86b4d41a ^

e087f6d4









86b4d41a ^

e087f6d4



86b4d41a ^
e087f6d4



86b4d41a ^

e087f6d4




86b4d41a ^

e087f6d4






86b4d41a ^
e087f6d4











86b4d41a ^
e087f6d4



86b4d41a ^
e087f6d4




86b4d41a ^

e087f6d4






86b4d41a ^
e087f6d4















86b4d41a ^
d7e8d7e4 ^
86b4d41a ^
e087f6d4
86b4d41a ^
e087f6d4
86b4d41a ^
57bfc74f ^












e087f6d4



86b4d41a ^




e087f6d4

86b4d41a ^
57bfc74f ^
e087f6d4

86b4d41a ^
e087f6d4
57bfc74f ^

86b4d41a ^
57bfc74f ^
e087f6d4
57bfc74f ^
e087f6d4

86b4d41a ^
0eae931d ^
e087f6d4
86b4d41a ^
e087f6d4
2a94396c ^
86b4d41a ^
5816641f ^
86b4d41a ^

e087f6d4



86b4d41a ^
e087f6d4
86b4d41a ^


e087f6d4











0eae931d ^
e087f6d4



0eae931d ^
e087f6d4

86b4d41a ^
e087f6d4

57bfc74f ^
15995566 ^
57bfc74f ^
e087f6d4

57bfc74f ^

86b4d41a ^
e087f6d4
03b222bb ^
51a6f85e ^
fb4db89a ^
e087f6d4



57bfc74f ^
86b4d41a ^
57bfc74f ^
51a6f85e ^
e087f6d4


6e75abc0 ^

e087f6d4


03b222bb ^
e087f6d4
fb4db89a ^
57bfc74f ^

e087f6d4

51f21bae ^
5816641f ^

51f21bae ^
5d4274ca ^




51f21bae ^
043745f9 ^

51a6f85e ^


e087f6d4
5d4274ca ^
e087f6d4
57bfc74f ^


86b4d41a ^
e087f6d4
86b4d41a ^
e087f6d4

03b222bb ^
51f21bae ^
03b222bb ^
51f21bae ^
51a6f85e ^

e087f6d4
57bfc74f ^
86b4d41a ^
57bfc74f ^

86b4d41a ^

57bfc74f ^
86b4d41a ^
e087f6d4



e087f6d4
6b6388d0 ^
5816641f ^

6e75abc0 ^
e087f6d4
57bfc74f ^
86b4d41a ^
57bfc74f ^
e087f6d4



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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660