2wm

dual window manager prototype (minimalist dwm with no tags, just one view)
git clone git://git.suckless.org/2wm
Log | Files | Refs | README | LICENSE

commit 8833d6c3ec623a8356be0347d97785c58f88a75c
parent a18db95399b52464cc4f9ca40b6277db3f88c534
Author: Anselm R. Garbe <arg@suckless.org>
Date:   Mon, 12 Feb 2007 12:20:21 +0100

removed more stuff
Diffstat:
2wm.h | 20+-------------------
client.c | 6+++---
config.default.h | 18+++++-------------
main.c | 25+++++--------------------
4 files changed, 14 insertions(+), 55 deletions(-)

diff --git a/2wm.h b/2wm.h @@ -11,30 +11,12 @@ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ typedef union { const char *cmd; int i; } Arg; /* argument type */ -typedef struct { - int ascent; - int descent; - int height; - XFontSet set; - XFontStruct *xfont; -} Fnt; - -typedef struct { - int x, y, w, h; - unsigned long norm[ColLast]; - unsigned long sel[ColLast]; - Drawable drawable; - Fnt font; - GC gc; -} DC; /* draw context */ - typedef struct Client Client; struct Client { char name[256]; @@ -63,7 +45,7 @@ extern Atom wmatom[WMLast], netatom[NetLast]; extern Bool running, selscreen, *seltag; /* seltag is array of Bool */ extern Client *clients, *sel, *stack; /* global client list and stack */ extern Cursor cursor[CurLast]; -extern DC dc; /* global draw context */ +extern unsigned long normcol, selcol; /* sel/normal color */ extern Display *dpy; extern Window root; diff --git a/client.c b/client.c @@ -90,7 +90,7 @@ focus(Client *c) { return; if(sel && sel != c) { grabbuttons(sel, False); - XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); + XSetWindowBorder(dpy, sel->win, normcol); } if(c) { detachstack(c); @@ -102,7 +102,7 @@ focus(Client *c) { if(!selscreen) return; if(c) { - XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); + XSetWindowBorder(dpy, c->win, selcol); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); } else @@ -177,7 +177,7 @@ manage(Window w, XWindowAttributes *wa) { StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); grabbuttons(c, False); - XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); + XSetWindowBorder(dpy, c->win, normcol); updatetitle(c); settags(c, getclient(trans)); if(!c->isfloat) diff --git a/config.default.h b/config.default.h @@ -7,32 +7,24 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; #define BORDERPX 1 #define DEFMODE dotile /* dofloat */ -#define FLOATSYMBOL "><>" -#define TILESYMBOL "[]=" -#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*" -#define NORMBORDERCOLOR "#333" -#define NORMBGCOLOR "#222" -#define NORMFGCOLOR "#ccc" -#define SELBORDERCOLOR "#69c" -#define SELBGCOLOR "#555" -#define SELFGCOLOR "#fff" +#define NORMCOLOR "#333" +#define SELCOLOR "#69c" #define MASTER 600 /* per thousand */ #define MODKEY Mod1Mask #define NMASTER 1 /* clients in master area */ #define SNAP 40 /* pixel */ -#define TOPBAR True /* False */ #define KEYS \ static Key key[] = { \ /* modifier key function argument */ \ { MODKEY|ShiftMask, XK_Return, spawn, \ - { .cmd = "exec uxterm -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \ + { .cmd = "exec uxterm -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*'" } }, \ { MODKEY, XK_p, spawn, \ { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ - " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ - "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ + " | dmenu -fn '-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*' -nb '#222' -nf '#ccc' " \ + "-sb '#555' -sf '#fff')\" && exec $exe" } }, \ { MODKEY, XK_j, focusnext, { 0 } }, \ { MODKEY, XK_k, focusprev, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \ diff --git a/main.c b/main.c @@ -17,8 +17,9 @@ /* extern */ -int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah; +int screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int master, nmaster, ntags, numlockmask; +unsigned long normcol, selcol; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; Bool *seltag; @@ -28,8 +29,7 @@ Client *sel = NULL; Client *stack = NULL; Cursor cursor[CurLast]; Display *dpy; -DC dc = {0}; -Window root, barwin; +Window root; /* static */ @@ -53,14 +53,7 @@ cleanup(void) { resize(stack, True); unmanage(stack); } - if(dc.font.set) - XFreeFontSet(dpy, dc.font.set); - else - XFreeFont(dpy, dc.font.xfont); XUngrabKey(dpy, AnyKey, AnyModifier, root); - XFreePixmap(dpy, dc.drawable); - XFreeGC(dpy, dc.gc); - XDestroyWindow(dpy, barwin); XFreeCursor(dpy, cursor[CurNormal]); XFreeCursor(dpy, cursor[CurResize]); XFreeCursor(dpy, cursor[CurMove]); @@ -131,12 +124,8 @@ setup(void) { seltag = emallocz(sizeof(Bool) * ntags); seltag[0] = True; /* style */ - dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); - dc.norm[ColBG] = getcolor(NORMBGCOLOR); - dc.norm[ColFG] = getcolor(NORMFGCOLOR); - dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); - dc.sel[ColBG] = getcolor(SELBGCOLOR); - dc.sel[ColFG] = getcolor(SELFGCOLOR); + normcol = getcolor(NORMCOLOR); + selcol = getcolor(SELCOLOR); /* geometry */ sx = sy = 0; sw = DisplayWidth(dpy, screen); @@ -148,10 +137,6 @@ setup(void) { way = sy; wah = sh; waw = sw; - /* pixmap for everything */ - dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); - dc.gc = XCreateGC(dpy, root, 0, 0); - XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); /* multihead support */ selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); }