diff -Naurp dwm-5.1-old/config.def.h dwm-5.1/config.def.h --- dwm-5.1-old/config.def.h 2008-07-29 13:18:32.000000000 -0500 +++ dwm-5.1/config.def.h 2008-08-16 16:39:01.000000000 -0500 @@ -1,20 +1,14 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const char font[] = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"; static const char normbordercolor[] = "#cccccc"; -static const char normbgcolor[] = "#cccccc"; -static const char normfgcolor[] = "#000000"; -static const char selbordercolor[] = "#0066ff"; -static const char selbgcolor[] = "#0066ff"; -static const char selfgcolor[] = "#ffffff"; -static unsigned int borderpx = 1; /* border pixel of windows */ +static const char selbordercolor[] = "#ff0000"; +static unsigned int borderpx = 2; /* border pixel of windows */ static unsigned int snap = 32; /* snap pixel */ -static Bool showbar = True; /* False means no bar */ -static Bool topbar = True; /* False means bottom bar */ /* tagging */ static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static Bool resizehints = True; /* False means respect size hints in tiled resizals */ static Rule rules[] = { /* class instance title tags mask isfloating */ @@ -24,13 +18,12 @@ static Rule rules[] = { /* layout(s) */ static float mfact = 0.55; -static Bool resizehints = True; /* False means respect size hints in tiled resizals */ static Layout layouts[] = { /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, + { tile }, /* first entry is default */ + { NULL }, /* no layout function means floating behavior */ + { monocle }, }; /* key definitions */ @@ -45,14 +38,13 @@ static Layout layouts[] = { #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ -static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-fn", "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*", "-nb", "#cccccc", "-nf", "#000000", "-sb", "#ff0000", "-sf", "#ffffff", NULL }; static const char *termcmd[] = { "uxterm", NULL }; static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, - { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, @@ -84,16 +76,8 @@ static Key keys[] = { * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; diff -Naurp dwm-5.1-old/dwm.c dwm-5.1/dwm.c --- dwm-5.1-old/dwm.c 2008-07-29 13:18:32.000000000 -0500 +++ dwm-5.1/dwm.c 2008-08-16 16:44:49.000000000 -0500 @@ -6,12 +6,9 @@ * events about window (dis-)appearance. Only one X connection at a time is * allowed to select for this event mask. * - * Calls to fetch an X event from the event queue are blocking. Due reading - * status text from standard input, a select()-driven main loop has been - * implemented which selects for reads on the X connection and STDIN_FILENO to - * handle all data smoothly. The event handlers of dwm are organized in an - * array which is accessed whenever a new event has been fetched. This allows - * event dispatching in O(1) time. + * The event handlers of dwm are organized in an array which is accessed + * whenever a new event has been fetched. This allows event dispatching in + * O(1) time. * * Each child of the root window is called a client, except windows which have * set the override_redirect flag. Clients are organized in a global @@ -24,7 +21,6 @@ * To understand everything else, start reading main(). */ #include -#include #include #include #include @@ -54,15 +50,13 @@ #define MAXTAGLEN 16 #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) -#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ +enum { ColBorder, ColLast }; /* color */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ +enum { ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ typedef union { int i; @@ -87,7 +81,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - Bool isfixed, isfloating, isurgent; + Bool isfixed, isfloating; Client *next; Client *snext; Window win; @@ -97,15 +91,7 @@ typedef struct { int x, y, w, h; unsigned long norm[ColLast]; unsigned long sel[ColLast]; - Drawable drawable; GC gc; - struct { - int ascent; - int descent; - int height; - XFontSet set; - XFontStruct *xfont; - } font; } DC; /* draw context */ typedef struct { @@ -116,7 +102,6 @@ typedef struct { } Key; typedef struct { - const char *symbol; void (*arrange)(void); } Layout; @@ -136,7 +121,6 @@ static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); static void cleanup(void); -static void clearurgent(void); static void configure(Client *c); static void configurenotify(XEvent *e); static void configurerequest(XEvent *e); @@ -144,24 +128,16 @@ static void destroynotify(XEvent *e); static void detach(Client *c); static void detachstack(Client *c); static void die(const char *errstr, ...); -static void drawbar(void); -static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); -static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); static void enternotify(XEvent *e); -static void expose(XEvent *e); static void focus(Client *c); static void focusin(XEvent *e); static void focusstack(const Arg *arg); static Client *getclient(Window w); static unsigned long getcolor(const char *colstr); static long getstate(Window w); -static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, Bool focused); static void grabkeys(void); -static void initfont(const char *fontstr); -static Bool isoccupied(unsigned int t); static Bool isprotodel(Client *c); -static Bool isurgent(unsigned int t); static void keypress(XEvent *e); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); @@ -183,19 +159,14 @@ static void setmfact(const Arg *arg); static void setup(void); static void spawn(const Arg *arg); static void tag(const Arg *arg); -static int textnw(const char *text, unsigned int len); static void tile(void); -static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unmanage(Client *c); static void unmapnotify(XEvent *e); -static void updatebar(void); static void updategeom(void); static void updatesizehints(Client *c); -static void updatetitle(Client *c); -static void updatewmhints(Client *c); static void view(const Arg *arg); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); @@ -203,9 +174,8 @@ static int xerrorstart(Display *dpy, XEr static void zoom(const Arg *arg); /* variables */ -static char stext[256]; static int screen, sx, sy, sw, sh; -static int by, bh, blw, wx, wy, ww, wh; +static int wx, wy, ww, wh; static unsigned int seltags = 0, sellt = 0; static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; @@ -215,7 +185,6 @@ static void (*handler[LASTEvent]) (XEven [ConfigureNotify] = configurenotify, [DestroyNotify] = destroynotify, [EnterNotify] = enternotify, - [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, [MappingNotify] = mappingnotify, @@ -234,7 +203,7 @@ static Cursor cursor[CurLast]; static Display *dpy; static DC dc = {0}; static Layout *lt[] = { NULL, NULL }; -static Window root, barwin; +static Window root; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -301,27 +270,12 @@ attachstack(Client *c) { void buttonpress(XEvent *e) { - unsigned int i, x, click; - Arg arg = {0}; + unsigned int i, click; Client *c; XButtonPressedEvent *ev = &e->xbutton; click = ClkRootWin; - if(ev->window == barwin) { - i = x = 0; - do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags)); - if(i < LENGTH(tags)) { - click = ClkTagBar; - arg.ui = 1 << i; - } - else if(ev->x < x + blw) - click = ClkLtSymbol; - else if(ev->x > wx + ww - TEXTW(stext)) - click = ClkStatusText; - else - click = ClkWinTitle; - } - else if((c = getclient(ev->window))) { + if((c = getclient(ev->window))) { focus(c); click = ClkClientWin; } @@ -329,7 +283,7 @@ buttonpress(XEvent *e) { for(i = 0; i < LENGTH(buttons); i++) if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) - buttons[i].func(click == ClkTagBar ? &arg : &buttons[i].arg); + buttons[i].func(&buttons[i].arg); } void @@ -350,46 +304,22 @@ checkotherwm(void) { void cleanup(void) { Arg a = {.i = ~0}; - Layout foo = { "", NULL }; + Layout foo = { NULL }; - close(STDIN_FILENO); view(&a); lt[sellt] = &foo; while(stack) 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); XFreeCursor(dpy, cursor[CurNormal]); XFreeCursor(dpy, cursor[CurResize]); XFreeCursor(dpy, cursor[CurMove]); - XDestroyWindow(dpy, barwin); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } void -clearurgent(void) { - XWMHints *wmh; - Client *c; - - for(c = clients; c; c = c->next) - if(ISVISIBLE(c) && c->isurgent) { - c->isurgent = False; - if (!(wmh = XGetWMHints(dpy, c->win))) - continue; - - wmh->flags &= ~XUrgencyHint; - XSetWMHints(dpy, c->win, wmh); - XFree(wmh); - } -} - -void configure(Client *c) { XConfigureEvent ce; @@ -415,7 +345,6 @@ configurenotify(XEvent *e) { sw = ev->width; sh = ev->height; updategeom(); - updatebar(); arrange(); } } @@ -499,100 +428,6 @@ die(const char *errstr, ...) { } void -drawbar(void) { - int i, x; - - dc.x = 0; - for(i = 0; i < LENGTH(tags); i++) { - dc.w = TEXTW(tags[i]); - if(tagset[seltags] & 1 << i) { - drawtext(tags[i], dc.sel, isurgent(i)); - drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); - } - else { - drawtext(tags[i], dc.norm, isurgent(i)); - drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm); - } - dc.x += dc.w; - } - if(blw > 0) { - dc.w = blw; - drawtext(lt[sellt]->symbol, dc.norm, False); - x = dc.x + dc.w; - } - else - x = dc.x; - dc.w = TEXTW(stext); - dc.x = ww - dc.w; - if(dc.x < x) { - dc.x = x; - dc.w = ww - x; - } - drawtext(stext, dc.norm, False); - if((dc.w = dc.x - x) > bh) { - dc.x = x; - if(sel) { - drawtext(sel->name, dc.sel, False); - drawsquare(sel->isfixed, sel->isfloating, False, dc.sel); - } - else - drawtext(NULL, dc.norm, False); - } - XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0); - XSync(dpy, False); -} - -void -drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { - int x; - XGCValues gcv; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - - gcv.foreground = col[invert ? ColBG : ColFG]; - XChangeGC(dpy, dc.gc, GCForeground, &gcv); - x = (dc.font.ascent + dc.font.descent + 2) / 4; - r.x = dc.x + 1; - r.y = dc.y + 1; - if(filled) { - r.width = r.height = x + 1; - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } - else if(empty) { - r.width = r.height = x; - XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } -} - -void -drawtext(const char *text, unsigned long col[ColLast], Bool invert) { - int i, x, y, h, len, olen; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - char buf[256]; - - XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]); - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - if(!text) - return; - olen = strlen(text); - len = MIN(olen, sizeof buf); - memcpy(buf, text, len); - h = dc.font.ascent + dc.font.descent; - y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; - x = dc.x + (h / 2); - /* shorten text if necessary */ - for(; len && (i = textnw(buf, len)) > dc.w - h; len--); - if(!len) - return; - if(len < olen) - for(i = len; i && i > len - 3; buf[--i] = '.'); - XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); - if(dc.font.set) - XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); - else - XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); -} - -void enternotify(XEvent *e) { Client *c; XCrossingEvent *ev = &e->xcrossing; @@ -606,14 +441,6 @@ enternotify(XEvent *e) { } void -expose(XEvent *e) { - XExposeEvent *ev = &e->xexpose; - - if(ev->count == 0 && (ev->window == barwin)) - drawbar(); -} - -void focus(Client *c) { if(!c || !ISVISIBLE(c)) for(c = stack; c && !ISVISIBLE(c); c = c->snext); @@ -631,7 +458,6 @@ focus(Client *c) { else XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); sel = c; - drawbar(); } void @@ -704,32 +530,6 @@ getstate(Window w) { return result; } -Bool -gettextprop(Window w, Atom atom, char *text, unsigned int size) { - char **list = NULL; - int n; - XTextProperty name; - - if(!text || size == 0) - return False; - text[0] = '\0'; - XGetTextProperty(dpy, w, &name, atom); - if(!name.nitems) - return False; - if(name.encoding == XA_STRING) - strncpy(text, (char *)name.value, size - 1); - else { - if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success - && n > 0 && *list) { - strncpy(text, *list, size - 1); - XFreeStringList(list); - } - } - text[size - 1] = '\0'; - XFree(name.value); - return True; -} - void grabbuttons(Client *c, Bool focused) { unsigned int i, j; @@ -775,56 +575,6 @@ grabkeys(void) { } } -void -initfont(const char *fontstr) { - char *def, **missing; - int i, n; - - missing = NULL; - if(dc.font.set) - XFreeFontSet(dpy, dc.font.set); - dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); - if(missing) { - while(n--) - fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); - XFreeStringList(missing); - } - if(dc.font.set) { - XFontSetExtents *font_extents; - XFontStruct **xfonts; - char **font_names; - dc.font.ascent = dc.font.descent = 0; - font_extents = XExtentsOfFontSet(dc.font.set); - n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); - for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { - dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); - dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); - xfonts++; - } - } - else { - if(dc.font.xfont) - XFreeFont(dpy, dc.font.xfont); - dc.font.xfont = NULL; - if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) - && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) - die("error, cannot load font: '%s'\n", fontstr); - dc.font.ascent = dc.font.xfont->ascent; - dc.font.descent = dc.font.xfont->descent; - } - dc.font.height = dc.font.ascent + dc.font.descent; -} - -Bool -isoccupied(unsigned int t) { - Client *c; - - for(c = clients; c; c = c->next) - if(c->tags & 1 << t) - return True; - return False; -} - Bool isprotodel(Client *c) { int i, n; @@ -840,16 +590,6 @@ isprotodel(Client *c) { return ret; } -Bool -isurgent(unsigned int t) { - Client *c; - - for(c = clients; c; c = c->next) - if(c->isurgent && c->tags & 1 << t) - return True; - return False; -} - void keypress(XEvent *e) { unsigned int i; @@ -894,7 +634,7 @@ manage(Window w, XWindowAttributes *wa) if(!(c = calloc(1, sizeof(Client)))) die("fatal: could not calloc() %u bytes\n", sizeof(Client)); c->win = w; - + /* geometry */ c->x = wa->x; c->y = wa->y; @@ -912,8 +652,7 @@ manage(Window w, XWindowAttributes *wa) if(c->y + c->h + 2 * c->bw > sy + sh) c->y = sy + sh - c->h - 2 * c->bw; c->x = MAX(c->x, sx); - /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy); + c->y = MAX(c->y, sy); c->bw = borderpx; } @@ -924,7 +663,6 @@ manage(Window w, XWindowAttributes *wa) updatesizehints(c); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); grabbuttons(c, False); - updatetitle(c); if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) for(t = clients; t && t->win != trans; t = t->next); if(t) @@ -1050,15 +788,6 @@ propertynotify(XEvent *e) { case XA_WM_NORMAL_HINTS: updatesizehints(c); break; - case XA_WM_HINTS: - updatewmhints(c); - drawbar(); - break; - } - if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { - updatetitle(c); - if(c == sel) - drawbar(); } } } @@ -1118,10 +847,6 @@ resize(Client *c, int x, int y, int w, i x = sx; if(y + h + 2 * c->bw < sy) y = sy; - if(h < bh) - h = bh; - if(w < bh) - w = bh; if(c->x != x || c->y != y || c->w != w || c->h != h) { c->x = wc.x = x; c->y = wc.y = y; @@ -1189,14 +914,12 @@ restack(void) { XEvent ev; XWindowChanges wc; - drawbar(); if(!sel) return; if(sel->isfloating || !lt[sellt]->arrange) XRaiseWindow(dpy, sel->win); if(lt[sellt]->arrange) { wc.stack_mode = Below; - wc.sibling = barwin; for(c = stack; c; c = c->snext) if(!c->isfloating && ISVISIBLE(c)) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); @@ -1209,61 +932,14 @@ restack(void) { void run(void) { - char *p; - char sbuf[sizeof stext]; - fd_set rd; - int r, xfd; - unsigned int len, offset; XEvent ev; - /* main event loop, also reads status text from stdin */ + /* main event loop */ XSync(dpy, False); - xfd = ConnectionNumber(dpy); - readin = True; - offset = 0; - len = sizeof stext - 1; - sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */ - while(running) { - FD_ZERO(&rd); - if(readin) - FD_SET(STDIN_FILENO, &rd); - FD_SET(xfd, &rd); - if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { - if(errno == EINTR) - continue; - die("select failed\n"); - } - if(FD_ISSET(STDIN_FILENO, &rd)) { - switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) { - case -1: - strncpy(stext, strerror(errno), len); - readin = False; - break; - case 0: - strncpy(stext, "EOF", 4); - readin = False; - break; - default: - for(p = sbuf + offset; r > 0; p++, r--, offset++) - if(*p == '\n' || *p == '\0') { - *p = '\0'; - strncpy(stext, sbuf, len); - p += r - 1; /* p is sbuf + offset + r - 1 */ - for(r = 0; *(p - r) && *(p - r) != '\n'; r++); - offset = r; - if(r) - memmove(sbuf, p - r + 1, r); - break; - } - break; - } - drawbar(); - } - while(XPending(dpy)) { - XNextEvent(dpy, &ev); - if(handler[ev.type]) - (handler[ev.type])(&ev); /* call handler */ - } + while(running) { + XNextEvent(dpy, &ev); + if(handler[ev.type]) + (handler[ev.type])(&ev); /* call handler */ } } @@ -1310,8 +986,6 @@ setlayout(const Arg *arg) { lt[sellt] = (Layout *)arg->v; if(sel) arrange(); - else - drawbar(); } /* arg > 1.0 will set mfact absolutly */ @@ -1330,19 +1004,15 @@ setmfact(const Arg *arg) { void setup(void) { - unsigned int i; - int w; XSetWindowAttributes wa; /* init screen */ screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); - initfont(font); sx = 0; sy = 0; sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); - bh = dc.h = dc.font.height + 2; lt[0] = &layouts[0]; lt[1] = &layouts[1 % LENGTH(layouts)]; updategeom(); @@ -1362,35 +1032,14 @@ setup(void) { /* init appearance */ 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); - dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, 0); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); - if(!dc.font.set) - XSetFont(dpy, dc.gc, dc.font.xfont->fid); - - /* init bar */ - for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) { - w = TEXTW(layouts[i].symbol); - blw = MAX(blw, w); - } wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask|ExposureMask; - barwin = XCreateWindow(dpy, root, wx, by, ww, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - XDefineCursor(dpy, barwin, cursor[CurNormal]); - XMapRaised(dpy, barwin); - strcpy(stext, "dwm-"VERSION); - drawbar(); - /* EWMH support per view */ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); @@ -1432,17 +1081,6 @@ tag(const Arg *arg) { } } -int -textnw(const char *text, unsigned int len) { - XRectangle r; - - if(dc.font.set) { - XmbTextExtents(dc.font.set, text, len, NULL, &r); - return r.width; - } - return XTextWidth(dc.font.xfont, text, len); -} - void tile(void) { int x, y, h, w, mw; @@ -1466,8 +1104,6 @@ tile(void) { y = wy; w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw; h = wh / n; - if(h < bh) - h = wh; for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) @@ -1478,14 +1114,6 @@ tile(void) { } void -togglebar(const Arg *arg) { - showbar = !showbar; - updategeom(); - updatebar(); - arrange(); -} - -void togglefloating(const Arg *arg) { if(!sel) return; @@ -1511,7 +1139,6 @@ toggleview(const Arg *arg) { if(mask) { tagset[seltags] = mask; - clearurgent(); arrange(); } } @@ -1548,14 +1175,6 @@ unmapnotify(XEvent *e) { } void -updatebar(void) { - if(dc.drawable != 0) - XFreePixmap(dpy, dc.drawable); - dc.drawable = XCreatePixmap(dpy, root, ww, bh, DefaultDepth(dpy, screen)); - XMoveResizeWindow(dpy, barwin, wx, by, ww, bh); -} - -void updategeom(void) { #ifdef XINERAMA int n, i = 0; @@ -1573,22 +1192,19 @@ updategeom(void) { break; } wx = info[i].x_org; - wy = showbar && topbar ? info[i].y_org + bh : info[i].y_org; + wy = info[i].y_org; ww = info[i].width; - wh = showbar ? info[i].height - bh : info[i].height; + wh = info[i].height; XFree(info); } else #endif { wx = sx; - wy = showbar && topbar ? sy + bh : sy; + wy = sy; ww = sw; - wh = showbar ? sh - bh : sh; + wh = sh; } - - /* bar position */ - by = showbar ? (topbar ? wy - bh : wy + wh) : -bh; } void @@ -1640,35 +1256,12 @@ updatesizehints(Client *c) { } void -updatetitle(Client *c) { - if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) - gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); -} - -void -updatewmhints(Client *c) { - XWMHints *wmh; - - if((wmh = XGetWMHints(dpy, c->win))) { - if(ISVISIBLE(c) && wmh->flags & XUrgencyHint) { - wmh->flags &= ~XUrgencyHint; - XSetWMHints(dpy, c->win, wmh); - } - else - c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; - - XFree(wmh); - } -} - -void view(const Arg *arg) { if(arg && (arg->i & TAGMASK) == tagset[seltags]) return; seltags ^= 1; /* toggle sel tagset */ if(arg && (arg->ui & TAGMASK)) tagset[seltags] = arg->i & TAGMASK; - clearurgent(); arrange(); } @@ -1727,9 +1320,6 @@ main(int argc, char *argv[]) { else if(argc != 1) die("usage: dwm [-v]\n"); - if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) - fprintf(stderr, "warning: no locale support\n"); - if(!(dpy = XOpenDisplay(0))) die("dwm: cannot open display\n");