changeset:   2251:b5da839c0588
tag:         tip
user:        Kris Maglione <jg_AT_suckless.org>
date:        Mon Jan 21 23:21:37 2008 -0500
summary:     Fix a fullscreen bug. Add setsid command to wmiir.
diff -r 80565821dd0c -r b5da839c0588 cmd/util.c
--- a/cmd/util.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/util.c	Mon Jan 21 23:21:37 2008 -0500
@@ -46,17 +46,25 @@ fatal(const char *fmt, ...) {
         exit(1);
 }
 
+void*
+freelater(void *p) {
+	static char*	obj[16];
+	static long	nobj;
+	int id;
+
+	id = nobj++ % nelem(obj);
+	free(obj[id]);
+	obj[id] = p;
+	return p;
+}
+
 char*
 vsxprint(const char *fmt, va_list ap) {
-	static char*	bufs[16];
-	static long	nbuf;
-	int id;
-
-	id = nbuf++ % nelem(bufs);
-	if(bufs[id])
-		free(bufs[id]);
-	bufs[id] = vsmprint(fmt, ap);
-	return bufs[id];
+	char *s;
+
+	s = vsmprint(fmt, ap);
+	freelater(s);
+	return s;
 }
 
 char*
@@ -93,19 +101,19 @@ mfatal(char *name, uint size) {
         char buf[1024];
         char sizestr[8];
         int i;
-	
-	i = sizeof(sizestr);
+
+	i = sizeof sizestr;
         do {
                 sizestr[--i] = '0' + (size%10);
                 size /= 10;
         } while(size > 0);
 
-	strlcat(buf, argv0, sizeof(buf));
-	strlcat(buf, couldnot, sizeof(buf));
-	strlcat(buf, name, sizeof(buf));
-	strlcat(buf, paren, sizeof(buf));
-	strlcat(buf, sizestr+i, sizeof(buf));
-	strlcat(buf, bytes, sizeof(buf));
+	strlcat(buf, argv0, sizeof buf);
+	strlcat(buf, couldnot, sizeof buf);
+	strlcat(buf, name, sizeof buf);
+	strlcat(buf, paren, sizeof buf);
+	strlcat(buf, sizestr+i, sizeof buf);
+	strlcat(buf, bytes, sizeof buf);
         write(2, buf, strlen(buf));
 
         exit(1);
@@ -204,3 +212,4 @@ strlcat(char *dst, const char *src, uint
                 *d = '\0';
         return size - n - 1;
 }
+
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii.sh.sh
--- a/cmd/wmii.sh.sh	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii.sh.sh	Mon Jan 21 23:21:37 2008 -0500
@@ -1,5 +1,4 @@
 
-wmiiscript=$1
 if [ -z "$scriptname" ]; then
         scriptname="$wmiiscript"; fi
 echo Start $wmiiscript | wmiir write /event 2>/dev/null ||
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/bar.c
--- a/cmd/wmii/bar.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/bar.c	Mon Jan 21 23:21:37 2008 -0500
@@ -1,12 +1,10 @@
-/* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
- * Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
+/* Copyright ©2006-2008 Kris Maglione <fbsdaemon_AT_gmail.com>
  * See LICENSE file for license details.
  */
 #include "dat.h"
 #include "fns.h"
 
 static Handlers handlers;
-static Bar *free_bars;
 
 #define foreach_bar(s, b) \
         for(int __bar_n=0; __bar_n < nelem((s)->bar); __bar_n++) \
@@ -25,10 +23,7 @@ bar_init(WMScreen *s) {
                   ExposureMask
                 | ButtonPressMask
                 | ButtonReleaseMask
-		| FocusChangeMask
-		| SubstructureRedirectMask
-		| SubstructureNotifyMask;
-
+		| FocusChangeMask;
         s->barwin = createwindow(&scr.root, s->brect, scr.depth, InputOutput, &wa,
                           CWOverrideRedirect
                         | CWBackPixmap
@@ -39,6 +34,20 @@ bar_init(WMScreen *s) {
         mapwin(s->barwin);
 }
 
+void
+bar_resize(WMScreen *s) {
+	View *v;
+
+	s->brect = s->r;
+	s->brect.min.y = s->brect.max.y - labelh(def.font);
+
+	reshapewin(s->barwin, s->brect);
+
+	bar_draw(s);
+	for(v=view; v; v=v->next)
+		view_arrange(v);
+}
+
 Bar*
 bar_create(Bar **bp, const char *name) {
         static uint id = 1;
@@ -50,16 +59,9 @@ bar_create(Bar **bp, const char *name) {
         if(b)
                 return b;
 
-	if(free_bars) {
-		b = free_bars;
-		free_bars = b->next;
-		memset(b, 0, sizeof(*b));
-	}
-	else
-		b = emallocz(sizeof(Bar));
-
+	b = emallocz(sizeof *b);
         b->id = id++;
-	utflcpy(b->name, name, sizeof(b->name));
+	utflcpy(b->name, name, sizeof b->name);
         b->col = def.normcolor;
 
         for(; *bp; bp = &bp[0]->next)
@@ -85,24 +87,7 @@ bar_destroy(Bar **bp, Bar *b) {
         for(p = bp; *p; p = &p[0]->next)
                 if(*p == b) break;
         *p = b->next;
-
-	b->next = free_bars;
-	free_bars = b;
-}
-
-void
-bar_resize(WMScreen *s) {
-	View *v;
-
-	s->brect = s->r;
-	s->brect.min.y = s->brect.max.y - labelh(def.font);
-
-	reshapewin(s->barwin, s->brect);
-
-	sync();
-	bar_draw(s);
-	for(v = view; v; v = v->next)
-		view_arrange(v);
+	free(b);
 }
 
 void
@@ -151,7 +136,7 @@ bar_draw(WMScreen *s) {
         foreach_bar(s, b) {
                 if(tb)
                         b->r = rectaddpt(b->r, Pt(tb->r.max.x, 0));
-		if(b == s->bar[BarRight])
+		if(b == s->bar[BRight])
                         b->r.max.x += Dx(s->brect) - width;
                 tb = b;
         }
@@ -160,7 +145,7 @@ bar_draw(WMScreen *s) {
         fill(screen->ibuf, r, def.normcolor.bg);
         foreach_bar(s, b) {
                 align = Center;
-		if(b == s->bar[BarRight])
+		if(b == s->bar[BRight])
                         align = East;
                 fill(screen->ibuf, b->r, b->col.bg);
                 drawstring(screen->ibuf, def.font, b->r, align, b->text, b->col.fg);
@@ -175,14 +160,14 @@ bar_find(Bar *bp, const char *name) {
         Bar *b;
 
         for(b = bp; b; b = b->next)
-		if(!strncmp(b->name, name, sizeof(b->name)))
+		if(!strcmp(b->name, name))
                         break;
         return b;
 }
 
 static char *barside[] = {
-	[BarLeft]  = "Left",
-	[BarRight] = "Right",
+	[BLeft]  = "Left",
+	[BRight] = "Right",
 };
 
 static Bar*
@@ -247,3 +232,4 @@ static Handlers handlers = {
         .dndmotion = dndmotion_event,
         .expose = expose_event,
 };
+
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/client.c
--- a/cmd/wmii/client.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/client.c	Mon Jan 21 23:21:37 2008 -0500
@@ -494,7 +494,8 @@ client_resize(Client *c, Rectangle r) {
                 client_configure(c);
                 ewmh_framesize(c);
         }
-
+	sync(); /* Not ideal. */
+	flushenterevents();
         flushevents(FocusChangeMask|ExposureMask, True);
 }
 
@@ -557,8 +558,12 @@ fullscreen(Client *c, int fullscreen) {
 
         if(!fullscreen)
                 for(f=c->frame; f; f=f->cnext) {
-			if(f->oldarea == 0)
+			if(f->oldarea == 0) {
                                 frame_resize(f, f->oldr); /* XXX: oldr Replace with floatr */
+				if(f->view == screen->sel) /* FIXME */
+					client_resize(f->client, f->r);
+
+			}
                         else if(f->oldarea > 0) {
                                 wassel = (f == f->area->sel);
                                 area_moveto(view_findarea(f->view, f->oldarea, true), f);
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/dat.h	Mon Jan 21 23:21:37 2008 -0500
@@ -275,7 +275,7 @@ EXTERN struct {
 } def;
 
 enum {
-	BarLeft, BarRight
+	BLeft, BRight
 };
 
 #define BLOCK(x) do { x; }while(0)
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/div.c
--- a/cmd/wmii/div.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/div.c	Mon Jan 21 23:21:37 2008 -0500
@@ -4,9 +4,10 @@
 #include "dat.h"
 #include "fns.h"
 
-static Image *divimg, *divmask;
-static CTuple divc;
-static Handlers handlers;
+static Image*	divimg;
+static Image*	divmask;
+static CTuple	divcolor;
+static Handlers	handlers;
 
 static Divide*
 getdiv(Divide **dp) {
@@ -92,7 +93,7 @@ update_imgs(void) {
 
         if(divimg) {
                 if(w == Dx(divimg->r) && h == Dy(divimg->r)
-		&& !memcmp(&divc, &def.normcolor, sizeof(divc)))
+		&& !memcmp(&divcolor, &def.normcolor, sizeof divcolor))
                         return;
                 freeimage(divimg);
                 freeimage(divmask);
@@ -100,11 +101,11 @@ update_imgs(void) {
 
         divimg = allocimage(w, h, scr.depth);
         divmask = allocimage(w, h, 1);
-	divc = def.normcolor;
+	divcolor = def.normcolor;
 
         fill(divmask, divmask->r, 0);
         drawimg(divmask, 1, 1);
-	drawimg(divimg, divc.bg, divc.border);
+	drawimg(divimg, divcolor.bg, divcolor.border);
 
         for(d = divs; d && d->w->mapped; d = d->next)
                 drawdiv(d);
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/ewmh.c	Mon Jan 21 23:21:37 2008 -0500
@@ -384,8 +384,8 @@ ewmh_framesize(Client *c) {
         f = c->sel;
         r.min.x = f->crect.min.x;
         r.min.y = f->crect.min.y;
-	r.max.x = f->r.max.x - f->crect.max.x;
-	r.max.y = f->r.max.y - f->crect.max.y;
+	r.max.x = Dx(f->r) - f->crect.max.x;
+	r.max.y = Dy(f->r) - f->crect.max.y;
 
         long extents[] = {
                 r.min.x, r.max.x,
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/fs.c	Mon Jan 21 23:21:37 2008 -0500
@@ -433,9 +433,9 @@ lookup_file(FileId *parent, char *name)
                         switch(file->tab.type) {
                         case FsDBars:
                                 if(!strcmp(file->tab.name, "lbar"))
-					file->p.bar_p = &screen[0].bar[BarLeft];
+					file->p.bar_p = &screen[0].bar[BLeft];
                                 else
-					file->p.bar_p = &screen[0].bar[BarRight];
+					file->p.bar_p = &screen[0].bar[BRight];
                                 break;
                         case FsFColRules:
                                 file->p.rule = &def.colrules;
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/main.c
--- a/cmd/wmii/main.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/main.c	Mon Jan 21 23:21:37 2008 -0500
@@ -241,6 +241,7 @@ errorhandler(Display *dpy, XErrorEvent *
         /* Try to cleanup, but only try once, in case we're called recursively. */
         if(!dead++)
                 cleanup();
+	abort();
         return xlib_errorhandler(display, error); /* calls exit() */
 }
 
diff -r 80565821dd0c -r b5da839c0588 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmii/x11.c	Mon Jan 21 23:21:37 2008 -0500
@@ -6,6 +6,7 @@
 #define ZR _ZR
 #define pointerwin __pointerwin
 #include "dat.h"
+#include <limits.h>
 #include <math.h>
 #include <unistd.h>
 #include <bio.h>
@@ -15,17 +16,16 @@
             * elsewhere. */
 #undef  pointerwin
 
-const Point ZP = {0, 0};
-const Rectangle ZR = {{0, 0}, {0, 0}};
-
-const Window _pointerwin = {
-	.w = PointerRoot
-};
-Window *const pointerwin = (Window*)&_pointerwin;
-
-static Map wmap, amap;
-static MapEnt* wbucket[137];
-static MapEnt* abucket[137];
+const Point	ZP = {0, 0};
+const Rectangle	ZR = {{0, 0}, {0, 0}};
+
+const Window	_pointerwin = { .w = PointerRoot };
+Window*		const pointerwin = (Window*)&_pointerwin;
+
+static Map	windowmap;
+static Map	atommap;
+static MapEnt*	wbucket[137];
+static MapEnt*	abucket[137];
 
 
 /* Rectangles/Points */
@@ -43,7 +43,7 @@ int
 int
 eqrect(Rectangle a, Rectangle b) {
         return a.min.x==b.min.x && a.max.x==b.max.x
-		&& a.min.y==b.min.y && a.max.y==b.max.y;
+	    && a.min.y==b.min.y && a.max.y==b.max.y;
 }
 
 int
@@ -165,10 +165,10 @@ initdisplay(void) {
         
         scr.root.parent = &scr.root;
 
-	wmap.bucket = wbucket;
-	wmap.nhash = nelem(wbucket);
-	amap.bucket = abucket;
-	amap.nhash = nelem(abucket);
+	windowmap.bucket = wbucket;
+	windowmap.nhash = nelem(wbucket);
+	atommap.bucket = abucket;
+	atommap.nhash = nelem(abucket);
 
         fmtinstall('A', Afmt);
         fmtinstall('R', Rfmt);
@@ -183,8 +183,8 @@ allocimage(int w, int h, int depth) {
 
         img = emallocz(sizeof *img);
         img->type = WImage;
-	img->image = XCreatePixmap(display, scr.root.w, w, h, depth);
-	img->gc = XCreateGC(display, img->image, 0, nil);
+	img->w = XCreatePixmap(display, scr.root.w, w, h, depth);
+	img->gc = XCreateGC(display, img->w, 0, nil);
         img->depth = depth;
         img->r = Rect(0, 0, w, h);
         return img;
@@ -194,16 +194,14 @@ freeimage(Image *img) {
 freeimage(Image *img) {
         assert(img->type == WImage);
 
-	XFreePixmap(display, img->image);
+	XFreePixmap(display, img->w);
         XFreeGC(display, img->gc);
         free(img);
 }
 
 /* Windows */
 Window*
-createwindow(Window *parent, Rectangle r, int depth, uint class,
-		WinAttr *wa, int valmask)
-		{
+createwindow(Window *parent, Rectangle r, int depth, uint class, WinAttr *wa, int valmask) {
         Window *w;
 
         assert(parent->type == WWindow);
@@ -214,11 +212,8 @@ createwindow(Window *parent, Rectangle r
 
         w->w =  XCreateWindow(display, parent->w, r.min.x, r.min.y, Dx(r), Dy(r),
                                 0 /* border */, depth, class, scr.visual, valmask, wa);
-
-	if(class != InputOnly) {
+	if(class != InputOnly)
                 w->gc = XCreateGC(display, w->w, 0, nil);
-		w->image = w->w;
-	}
 
         w->r = r;
         w->depth = depth;
@@ -226,12 +221,13 @@ createwindow(Window *parent, Rectangle r
 }
 
 Window*
-window(XWindow w) {
-	static Window win;
-
-	win.type = WWindow;
-	win.w = w;
-	return &win;
+window(XWindow xw) {
+	Window *w;
+
+	w = malloc(sizeof *w);
+	w->type = WWindow;
+	w->w = xw;
+	return freelater(w);
 }
 
 void
@@ -316,9 +312,9 @@ sethandler(Window *w, Handlers *new) {
         assert((w->prev != nil && w->next != nil) || w->next == w->prev);
 
         if(new == nil)
-		map_rm(&wmap, (ulong)w->w);
+		map_rm(&windowmap, (ulong)w->w);
         else {
-		e = map_get(&wmap, (ulong)w->w, 1);
+		e = map_get(&windowmap, (ulong)w->w, 1);
                 e->val = w;
         }
         old = w->handler;
@@ -330,7 +326,7 @@ findwin(XWindow w) {
 findwin(XWindow w) {
         MapEnt *e;
         
-	e = map_get(&wmap, (ulong)w, 0);
+	e = map_get(&windowmap, (ulong)w, 0);
         if(e)
                 return e->val;
         return nil;
@@ -346,7 +342,7 @@ setshapemask(Window *dst, Image *src, Po
 setshapemask(Window *dst, Image *src, Point pt) {
         /* Assumes that we have the shape extension... */
         XShapeCombineMask (display, dst->w,
-		ShapeBounding, pt.x, pt.y, src->image, ShapeSet);
+		ShapeBounding, pt.x, pt.y, src->w, ShapeSet);
 }
 
 static void
@@ -366,14 +362,14 @@ border(Image *dst, Rectangle r, int w, u
 
         XSetLineAttributes(display, dst->gc, w, LineSolid, CapButt, JoinMiter);
         setgccol(dst, col);
-	XDrawRectangle(display, dst->image, dst->gc,
+	XDrawRectangle(display, dst->w, dst->gc,
                         r.min.x, r.min.y, Dx(r), Dy(r));
 }
 
 void
 fill(Image *dst, Rectangle r, ulong col) {
         setgccol(dst, col);
-	XFillRectangle(display, dst->image, dst->gc,
+	XFillRectangle(display, dst->w, dst->gc,
                 r.min.x, r.min.y, Dx(r), Dy(r));
 }
 
@@ -397,7 +393,7 @@ drawpoly(Image *dst, Point *pt, int np, 
         xp = convpts(pt, np);
         XSetLineAttributes(display, dst->gc, w, LineSolid, cap, JoinMiter);
         setgccol(dst, col);
-	XDrawLines(display, dst->image, dst->gc, xp, np, CoordModeOrigin);
+	XDrawLines(display, dst->w, dst->gc, xp, np, CoordModeOrigin);
         free(xp);
 }
 
@@ -407,7 +403,7 @@ fillpoly(Image *dst, Point *pt, int np, 
 
         xp = convpts(pt, np);
         setgccol(dst, col);
-	XFillPolygon(display, dst->image, dst->gc, xp, np, Complex, CoordModeOrigin);
+	XFillPolygon(display, dst->w, dst->gc, xp, np, Complex, CoordModeOrigin);
         free(xp);
 }
 
@@ -415,13 +411,13 @@ drawline(Image *dst, Point p1, Point p2,
 drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col) {
         XSetLineAttributes(display, dst->gc, w, LineSolid, cap, JoinMiter);
         setgccol(dst, col);
-	XDrawLine(display, dst->image, dst->gc, p1.x, p1.y, p2.x, p2.y);
+	XDrawLine(display, dst->w, dst->gc, p1.x, p1.y, p2.x, p2.y);
 }
 
 uint
 drawstring(Image *dst, Font *font,
-		Rectangle r, Align align,
-		char *text, ulong col) {
+	   Rectangle r, Align align,
+	   char *text, ulong col) {
         char *buf;
         uint x, y, w, h, len;
         int shortened;
@@ -465,13 +461,13 @@ drawstring(Image *dst, Font *font,
 
         setgccol(dst, col);
         if(font->set)
-		Xutf8DrawString(display, dst->image, 
+		Xutf8DrawString(display, dst->w, 
                                 font->set, dst->gc,
                                 x, y,
                                 buf, len);
         else {
                 XSetFont(display, dst->gc, font->xfont->fid);
-		XDrawString(display, dst->image, dst->gc,
+		XDrawString(display, dst->w, dst->gc,
                                 x, y,
                                 buf, len);
         }
@@ -484,10 +480,10 @@ void
 void
 copyimage(Image *dst, Rectangle r, Image *src, Point p) {
         XCopyArea(display,
-		src->image, dst->image,
-		dst->gc,
-		r.min.x, r.min.y, Dx(r), Dy(r),
-		p.x, p.y);
+		  src->w, dst->w,
+		  dst->gc,
+		  r.min.x, r.min.y, Dx(r), Dy(r),
+		  p.x, p.y);
 }
 
 /* Colors */
@@ -497,22 +493,22 @@ namedcolor(char *name, ulong *ret) {
 
         if(XAllocNamedColor(display, scr.colormap, name, &c, &c2)) {
                 *ret = c.pixel;
-		return 1;
-	}
-	return 0;
+		return true;
+	}
+	return false;
 }
 
 bool
 loadcolor(CTuple *c, char *str) {
         char buf[24];
 
-	utflcpy(buf, str, sizeof(buf));
+	utflcpy(buf, str, sizeof buf);
         memcpy(c->colstr, str, sizeof c->colstr);
 
         buf[7] = buf[15] = buf[23] = '\0';
         return namedcolor(buf, &c->fg)
-		&& namedcolor(buf+8, &c->bg)
-		&& namedcolor(buf+16, &c->border);
+	    && namedcolor(buf+8, &c->bg)
+	    && namedcolor(buf+16, &c->border);
 }
 
 /* Fonts */
@@ -533,7 +529,7 @@ loadfont(char *name) {
                 Bprint(b, "%s: note: missing fontset%s for '%s':", argv0,
                                 (n > 1 ? "s" : ""), name);
                 for(i = 0; i < n; i++)
-			Bprint(b, "%s %s", (i ? "," : ""), missing[i]);
+			Bprint(b, "%s %s", i?",":"", missing[i]);
                 Bprint(b, "\n");
                 Bterm(b);
                 freestringlist(missing);
@@ -543,8 +539,7 @@ loadfont(char *name) {
                 XFontsOfFontSet(f->set, &xfonts, &font_names);
                 f->ascent = xfonts[0]->ascent;
                 f->descent = xfonts[0]->descent;
-	}
-	else {
+	}else {
                 f->xfont = XLoadQueryFont(display, name);
                 if(!f->xfont) {
                         fprint(2, "%s: cannot load font: %s\n", argv0, name);
@@ -595,7 +590,7 @@ xatom(char *name) {
 xatom(char *name) {
         MapEnt *e;
         
-	e = hash_get(&amap, name, 1);
+	e = hash_get(&atommap, name, 1);
         if(e->val == nil)
                 e->val = (void*)XInternAtom(display, name, False);
         return (Atom)e->val;
@@ -851,7 +846,6 @@ ungrabpointer(void) {
 /* Insanity */
 void
 sethints(Window *w) {
-	enum { MaxInt = ((uint)(1<<(8*sizeof(int)-1))-1) };
         XSizeHints xs;
         XWMHints *wmh;
         WinHints *h;
@@ -864,12 +858,12 @@ sethints(Window *w) {
         h = w->hints;
         memset(h, 0, sizeof *h);
 
-	h->max = Pt(MaxInt, MaxInt);
+	h->max = Pt(INT_MAX, INT_MAX);
         h->inc = Pt(1,1);
 
         wmh = XGetWMHints(display, w->w);
         if(wmh) {
-		if(wmh->flags&WindowGroupHint)
+		if(wmh->flags & WindowGroupHint)
                         h->group = wmh->window_group;
                 free(wmh);
         }
@@ -877,45 +871,40 @@ sethints(Window *w) {
         if(!XGetWMNormalHints(display, w->w, &xs, &size))
                 return;
 
-	if(xs.flags&PMinSize) {
-		p.x = xs.min_width;
-		p.y = xs.min_height;
-		h->min = p;
-	}
-	if(xs.flags&PMaxSize) {
-		p.x = xs.max_width;
-		p.y = xs.max_height;
-		h->max = p;
+	if(xs.flags & PMinSize) {
+		h->min.x = xs.min_width;
+		h->min.y = xs.min_height;
+	}
+	if(xs.flags & PMaxSize) {
+		h->max.x = xs.max_width;
+		h->max.y = xs.max_height;
         }
 
         h->base = h->min;
-	if(xs.flags&PBaseSize) {
+	if(xs.flags & PBaseSize) {
                 p.x = xs.base_width;
                 p.y = xs.base_height;
                 h->base = p;
                 h->baspect = p;
         }
 
-	if(xs.flags&PResizeInc) {
+	if(xs.flags & PResizeInc) {
                 h->inc.x = max(xs.width_inc, 1);
                 h->inc.y = max(xs.height_inc, 1);
         }
 
-	if(xs.flags&PAspect) {
-		p.x = xs.min_aspect.x;
-		p.y = xs.min_aspect.y;
-		h->aspect.min = p;
-		p.x = xs.max_aspect.x;
-		p.y = xs.max_aspect.y;
-		h->aspect.max = p;
-	}
-	
-	h->position = ((xs.flags&(USPosition|PPosition)) != 0);
+	if(xs.flags & PAspect) {
+		h->aspect.min.x = xs.min_aspect.x;
+		h->aspect.min.y = xs.min_aspect.y;
+		h->aspect.max.x = xs.max_aspect.x;
+		h->aspect.max.y = xs.max_aspect.y;
+	}
+
+	h->position = ((xs.flags & (USPosition|PPosition)) != 0);
 
         p = ZP;
-	if((xs.flags&PWinGravity) == 0)
+	if(!(xs.flags & PWinGravity))
                 xs.win_gravity = NorthWestGravity;
-
         switch (xs.win_gravity) {
         case EastGravity:
         case CenterGravity:
@@ -946,13 +935,13 @@ sethints(Window *w) {
 
 Rectangle
 sizehint(WinHints *h, Rectangle r) {
-	Point p, p2, o;
+	Point p, aspect, origin;
 
         if(h == nil)
                 return r;
 
-	o = r.min;
-	r = rectsubpt(r, o);
+	origin = r.min;
+	r = rectsubpt(r, origin);
 
         /* Min/max */
         r.max.x = max(r.max.x, h->min.x);
@@ -968,25 +957,27 @@ sizehint(WinHints *h, Rectangle r) {
         /* Aspect */
         p = subpt(r.max, h->baspect);
         p.y = max(p.y, 1);
-	p2 = h->aspect.min;
-	if(p.x * p2.y / p.y < p2.x)
-		r.max.y = h->baspect.y + p.x * p2.y / p2.x;
-	p2 = h->aspect.max;
-	if(p.x * p2.y / p.y > p2.x)
-		r.max.x = h->baspect.x + p.y * p2.x / p2.y;
-
-	return rectaddpt(r, o);
+
+	aspect = h->aspect.min;
+	if(p.x * aspect.y / p.y < aspect.x)
+		r.max.y = h->baspect.y
+			+ p.x * aspect.y / aspect.x;
+
+	aspect = h->aspect.max;
+	if(p.x * aspect.y / p.y > aspect.x)
+		r.max.x = h->baspect.x
+		        + p.y * aspect.x / aspect.y;
+
+	return rectaddpt(r, origin);
 }
 
 Rectangle
 gravitate(Rectangle rc, Rectangle rf, Point grav) {
         Point d;
 
-	rf = rectsubpt(rf, rf.min);
-
         /* Get delta between frame and client rectangles */
-	d = subpt(rc.max, rc.min);
-	d = subpt(rf.max, d);
+	d = subpt(subpt(rf.max, rf.min),
+		  subpt(rc.max, rc.min));
 
         /* Divide by 2 and apply gravity */
         d = divpt(d, Pt(2, 2));
@@ -994,3 +985,4 @@ gravitate(Rectangle rc, Rectangle rf, Po
 
         return rectsubpt(rc, d);
 }
+
diff -r 80565821dd0c -r b5da839c0588 cmd/wmiir.c
--- a/cmd/wmiir.c	Mon Jan 21 18:22:42 2008 -0500
+++ b/cmd/wmiir.c	Mon Jan 21 23:21:37 2008 -0500
@@ -300,19 +300,41 @@ xls(int argc, char *argv[]) {
         return 0;
 }
 
+static int
+xsetsid(int argc, char *argv[]) {
+	char *av0;
+
+	av0 = nil;
+	ARGBEGIN{
+	case '0':
+		av0 = EARGF(usage());
+		break;
+	default:
+		usage();
+	}ARGEND;
+	if(av0 == nil)
+		av0 = argv[0];
+
+	setsid();
+	execvp(av0, argv);
+	fatal("setsid: can't exec: %r");
+	return 1; /* NOTREACHED */
+}
+
 typedef struct exectab exectab;
 struct exectab {
         char *cmd;
         int (*fn)(int, char**);
 } etab[] = {
+	{"cat", xread},
+	{"create", xcreate},
+	{"ls", xls},
+	{"read", xread},
+	{"remove", xremove},
+	{"rm", xremove},
+	{"setsid", xsetsid},
         {"write", xwrite},
         {"xwrite", xawrite},
-	{"read", xread},
-	{"cat", xread},
-	{"create", xcreate},
-	{"remove", xremove},
-	{"rm", xremove},
-	{"ls", xls},
         {0, 0}
 };
 
diff -r 80565821dd0c -r b5da839c0588 include/util.h
--- a/include/util.h	Mon Jan 21 18:22:42 2008 -0500
+++ b/include/util.h	Mon Jan 21 23:21:37 2008 -0500
@@ -15,7 +15,7 @@
 #define ushort	_x_ushort
 #define uint	_x_uint
 #define ulong	_x_ulong
-#define uvlong _x_uvlong
+#define uvlong	_x_uvlong
 #define vlong	_x_vlong
 
 typedef unsigned char		uchar;
@@ -34,6 +34,7 @@ void*	erealloc(void*, uint);
 void*	erealloc(void*, uint);
 char*	estrdup(const char*);
 void	fatal(const char*, ...);
+void*	freelater(void*);
 int	max(int, int);
 int	min(int, int);
 uint	strlcat(char*, const char*, uint);
diff -r 80565821dd0c -r b5da839c0588 include/x11.h
--- a/include/x11.h	Mon Jan 21 18:22:42 2008 -0500
+++ b/include/x11.h	Mon Jan 21 23:21:37 2008 -0500
@@ -112,8 +112,7 @@ struct WinHints {
 
 struct Window {
         int		type;
-	XWindow		w;
-	Drawable	image;
+	XID		w;
         GC		gc;
         Rectangle	r;
         Window*		parent;
diff -r 80565821dd0c -r b5da839c0588 rc/wmiirc.sh
--- a/rc/wmiirc.sh	Mon Jan 21 18:22:42 2008 -0500
+++ b/rc/wmiirc.sh	Mon Jan 21 23:21:37 2008 -0500
@@ -1,6 +1,7 @@
 #!/bin/sh -f
 # Configure wmii
-. wmii.sh wmiirc
+wmiiscript=wmiirc # For wmii.sh
+. wmii.sh
 
 # Configuration Variables
 MODKEY=Mod1
@@ -63,6 +64,19 @@ wi_events -s '	' <<'!'
         Event LeftBarClick LeftBarDND
                 shift
                 wmiir xwrite /ctl view "$@"
+	Event ClientMouseDown
+		client=$1; button=$2
+		case "$button" in
+		3)
+			do=$(wi_9menu -initial "$menulast" Nop Delete Fullscreen)
+			case "$do" in
+			Delete)
+				wmiir xwrite /client/$client/ctl kill;;
+			Fullscreen)
+				wmiir xwrite /client/$client/ctl Fullscreen on;;
+			esac
+			menulast=${do:-"$menulast"}
+		esac
         Event Unresponsive
                 {
                         client=$1; shift
@@ -96,19 +110,6 @@ wi_events -s '	' <<'!'
                 while status | wmiir write /rbar/status; do
                         sleep 1
                 done
-	Event ClientMouseDown
-		client=$1; button=$2
-		case "$button" in
-		3)
-			do=$(wi_9menu -initial "${menulast:-SomeRandomName}" Nop Delete Fullscreen)
-			case "$do" in
-			Delete)
-				wmiir xwrite /client/$client/ctl kill;;
-			Fullscreen)
-				wmiir xwrite /client/$client/ctl Fullscreen on;;
-			esac
-			menulast=${do:-"$menulast"}
-		esac
         # Key Bindings
         Key $MODKEY-Control-t
                 case $(wmiir read /keys | wc -l | tr -d ' \t\n') in
@@ -130,9 +131,9 @@ wi_events -s '	' <<'!'
         Key $MODKEY-a
                 Action $(wi_actions | wi_menu) &
         Key $MODKEY-p
-		sh -c "$(wi_menu <$progsfile)" &
+		wmiir setsid "$(wi_menu <$progsfile)" &
         Key $MODKEY-t
-		wmiir xwrite /ctl "view $(wi_tags | wi_menu)" &
+		wmiir xwrite /ctl view $(wi_tags | wi_menu) &
         Key $MODKEY-Return
                 eval $WMII_TERM &
         Key $MODKEY-Shift-space
@@ -142,7 +143,7 @@ wi_events -s '	' <<'!'
         Key $MODKEY-Shift-c
                 wmiir xwrite /client/sel/ctl kill
         Key $MODKEY-Shift-t
-		wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" "$(wi_tags | wi_menu)" &
+		wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" $(wi_tags | wi_menu) &
         Key $MODKEY-$LEFT
                 wmiir xwrite /tag/sel/ctl select left
         Key $MODKEY-$RIGHT
Received on Tue Jan 22 2008 - 05:22:24 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:59:06 UTC