Compare commits

..

16 Commits
3.0 ... 3.1

Author SHA1 Message Date
9715ba82aa removed erealloc (not used) 2007-01-16 11:35:56 +01:00
3c35b90dd3 removed unnecessary bx, by, bw variables 2007-01-16 11:33:42 +01:00
1d63030665 s/444/555/g - enlightened selected background 2007-01-16 11:28:17 +01:00
6a5b41203e removed firefox rule from default.h 2007-01-16 11:26:15 +01:00
fbd310972d applied new default colors 2007-01-16 11:25:10 +01:00
3059c9c507 applied sanders patch of my config 2007-01-16 11:12:34 +01:00
3b18f17d4d Jukka, thanks for being faster than me! 2007-01-15 19:01:57 +01:00
72faa1919e changed restack, to fix undrawed tag indicators 2007-01-15 12:07:18 +01:00
f8181f64e2 removed drawclient and drawall (they performed useless operations/consumed useless cpu cycles) 2007-01-15 12:04:25 +01:00
0045ad87df implemented new color scheme accordingly to Sanders proposal 2007-01-14 22:37:34 +01:00
ceea528eff removed mode label stuff 2007-01-14 22:32:26 +01:00
6c5dc7017c removed client title bar 2007-01-14 22:27:29 +01:00
ae0b4fdd92 added missing space 2007-01-12 21:56:01 +01:00
b3cea4d388 nah the last change feels bad 2007-01-12 13:06:15 +01:00
d296081321 changed incnmaster shortcuts in config.arg.h 2007-01-12 12:48:51 +01:00
177ed7e5de Added tag 3.0 for changeset 76b58d21ea98 2007-01-12 12:37:12 +01:00
12 changed files with 46 additions and 159 deletions

View File

@ -29,3 +29,4 @@ c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
21951c0dfbae5af68ed77821a4d87253ee91803f 2.7 21951c0dfbae5af68ed77821a4d87253ee91803f 2.7
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8 107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9 3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0

View File

@ -60,12 +60,6 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
/* extern functions */ /* extern functions */
void
ban(Client *c) {
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
}
void void
configure(Client *c) { configure(Client *c) {
XEvent synev; XEvent synev;
@ -96,7 +90,7 @@ focus(Client *c) {
sel = c; sel = c;
if(old) { if(old) {
grabbuttons(old, False); grabbuttons(old, False);
drawclient(old); XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
} }
} }
if(c) { if(c) {
@ -104,11 +98,12 @@ focus(Client *c) {
c->snext = stack; c->snext = stack;
stack = c; stack = c;
grabbuttons(c, True); grabbuttons(c, True);
drawclient(c); XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
} }
else else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
drawstatus();
} }
Client * Client *
@ -121,16 +116,6 @@ getclient(Window w) {
return NULL; return NULL;
} }
Client *
getctitle(Window w) {
Client *c;
for(c = clients; c; c = c->next)
if(c->twin == w)
return c;
return NULL;
}
void void
killclient(Arg *arg) { killclient(Arg *arg) {
if(!sel) if(!sel)
@ -145,17 +130,15 @@ void
manage(Window w, XWindowAttributes *wa) { manage(Window w, XWindowAttributes *wa) {
Client *c; Client *c;
Window trans; Window trans;
XSetWindowAttributes twa;
c = emallocz(sizeof(Client)); c = emallocz(sizeof(Client));
c->tags = emallocz(ntags * sizeof(Bool)); c->tags = emallocz(ntags * sizeof(Bool));
c->win = w; c->win = w;
c->border = 0; c->border = 0;
c->x = c->tx = wa->x; c->x = wa->x;
c->y = c->ty = wa->y; c->y = wa->y;
c->w = c->tw = wa->width; c->w = wa->width;
c->h = wa->height; c->h = wa->height;
c->th = bh;
updatesizehints(c); updatesizehints(c);
if(c->x + c->w + 2 * BORDERPX > sw) if(c->x + c->w + 2 * BORDERPX > sw)
c->x = sw - c->w - 2 * BORDERPX; c->x = sw - c->w - 2 * BORDERPX;
@ -169,27 +152,18 @@ manage(Window w, XWindowAttributes *wa) {
XSelectInput(dpy, c->win, XSelectInput(dpy, c->win,
StructureNotifyMask | PropertyChangeMask | EnterWindowMask); StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &trans); XGetTransientForHint(dpy, c->win, &trans);
twa.override_redirect = 1;
twa.background_pixmap = ParentRelative;
twa.event_mask = ExposureMask | EnterWindowMask;
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
0, DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
grabbuttons(c, False); grabbuttons(c, False);
updatetitle(c); updatetitle(c);
settags(c, getclient(trans)); settags(c, getclient(trans));
if(!c->isfloat) if(!c->isfloat)
c->isfloat = trans || c->isfixed; c->isfloat = trans || c->isfixed;
resizetitle(c);
if(clients) if(clients)
clients->prev = c; clients->prev = c;
c->next = clients; c->next = clients;
c->snext = stack; c->snext = stack;
stack = clients = c; stack = clients = c;
ban(c); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);
XMapWindow(dpy, c->twin);
if(isvisible(c)) if(isvisible(c))
focus(c); focus(c);
arrange(); arrange();
@ -228,7 +202,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
c->x = sw - c->w; c->x = sw - c->w;
if(c->y > sh) if(c->y > sh)
c->y = sh - c->h; c->y = sh - c->h;
resizetitle(c);
wc.x = c->x; wc.x = c->x;
wc.y = c->y; wc.y = c->y;
wc.width = c->w; wc.width = c->w;
@ -242,19 +215,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
XSync(dpy, False); XSync(dpy, False);
} }
void
resizetitle(Client *c) {
c->tw = textw(c->name);
if(c->tw > c->w)
c->tw = c->w + 2 * BORDERPX;
c->tx = c->x + c->w - c->tw + 2 * BORDERPX;
c->ty = c->y;
if(isvisible(c))
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
else
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
}
void void
updatesizehints(Client *c) { updatesizehints(Client *c) {
long msize; long msize;
@ -331,7 +291,6 @@ unmanage(Client *c) {
focus(nc); focus(nc);
} }
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);
free(c->tags); free(c->tags);
free(c); free(c);
XSync(dpy, False); XSync(dpy, False);

View File

@ -7,15 +7,15 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
#define DEFMODE dotile /* dofloat */ #define DEFMODE dotile /* dofloat */
#define FLOATSYMBOL "><>" #define FLOATSYMBOL "><>"
#define TILESYMBOL "[%u]=" /* %u is replaced with nmaster */ #define TILESYMBOL "[]="
#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*" #define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*"
#define NORMBORDERCOLOR "#333"
#define NORMBGCOLOR "#222" #define NORMBGCOLOR "#222"
#define NORMFGCOLOR "#ccc" #define NORMFGCOLOR "#ccc"
#define SELBGCOLOR "#444" #define SELBORDERCOLOR "#9cf"
#define SELBGCOLOR "#555"
#define SELFGCOLOR "#fff" #define SELFGCOLOR "#fff"
#define STATUSBGCOLOR "#333"
#define STATUSFGCOLOR "#9cf"
#define MASTER 600 /* per thousand */ #define MASTER 600 /* per thousand */
#define MODKEY Mod1Mask #define MODKEY Mod1Mask
@ -24,7 +24,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
#define KEYS \ #define KEYS \
static Key key[] = { \ static Key key[] = { \
/* modifier key function argument */ \ /* modifier key function argument */ \
{ MODKEY|ShiftMask, XK_Return, spawn, \ { 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 '"FONT"'" } }, \
{ MODKEY, XK_p, spawn, \ { MODKEY, XK_p, spawn, \

View File

@ -7,15 +7,15 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
#define DEFMODE dotile /* dofloat */ #define DEFMODE dotile /* dofloat */
#define FLOATSYMBOL "><>" #define FLOATSYMBOL "><>"
#define TILESYMBOL "[%u]=" /* %u is replaced with nmaster */ #define TILESYMBOL "[]="
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*" #define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
#define NORMBGCOLOR "#333366" #define NORMBORDERCOLOR "#dddddd"
#define NORMFGCOLOR "#cccccc" #define NORMBGCOLOR "#eeeeee"
#define SELBGCOLOR "#666699" #define NORMFGCOLOR "#222222"
#define SELFGCOLOR "#eeeeee" #define SELBORDERCOLOR "#ff0000"
#define STATUSBGCOLOR "#dddddd" #define SELBGCOLOR "#006699"
#define STATUSFGCOLOR "#222222" #define SELFGCOLOR "#ffffff"
#define MASTER 600 /* per thousand */ #define MASTER 600 /* per thousand */
#define MODKEY Mod1Mask #define MODKEY Mod1Mask
@ -82,6 +82,5 @@ static Key key[] = { \
#define RULES \ #define RULES \
static Rule rule[] = { \ static Rule rule[] = { \
/* class:instance:title regex tags regex isfloat */ \ /* class:instance:title regex tags regex isfloat */ \
{ "Firefox.*", "2", False }, \
{ "Gimp.*", NULL, True }, \ { "Gimp.*", NULL, True }, \
}; };

View File

@ -1,5 +1,5 @@
# dwm version # dwm version
VERSION = 3.0 VERSION = 3.1
# Customize below to fit your system # Customize below to fit your system

36
draw.c
View File

@ -97,15 +97,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
/* extern */ /* extern */
void
drawall(void) {
Client *c;
for(c = clients; c; c = getnext(c->next))
drawclient(c);
drawstatus();
}
void void
drawstatus(void) { drawstatus(void) {
int i, x; int i, x;
@ -120,37 +111,20 @@ drawstatus(void) {
dc.x += dc.w; dc.x += dc.w;
} }
dc.w = bmw; dc.w = bmw;
drawtext(mtext, dc.status, False, False); drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False);
x = dc.x + dc.w; x = dc.x + dc.w;
dc.w = textw(stext); dc.w = textw(stext);
dc.x = bw - dc.w; dc.x = sw - dc.w;
if(dc.x < x) { if(dc.x < x) {
dc.x = x; dc.x = x;
dc.w = bw - x; dc.w = sw - x;
} }
drawtext(stext, dc.status, False, False); drawtext(stext, dc.norm, False, False);
if((dc.w = dc.x - x) > bh) { if((dc.w = dc.x - x) > bh) {
dc.x = x; dc.x = x;
drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False); drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False);
} }
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
XSync(dpy, False);
}
void
drawclient(Client *c) {
if(c == sel && issel) {
drawstatus();
XUnmapWindow(dpy, c->twin);
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
return;
}
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
XMapWindow(dpy, c->twin);
dc.x = dc.y = 0;
dc.w = c->tw;
drawtext(c->name, dc.norm, False,False);
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
XSync(dpy, False); XSync(dpy, False);
} }

1
dwm.1
View File

@ -26,7 +26,6 @@ which are applied to one or more windows are indicated with an empty square in
the top left corner. the top left corner.
.P .P
dwm draws a 1-pixel border around windows to indicate the focus state. dwm draws a 1-pixel border around windows to indicate the focus state.
Unfocused windows contain a small bar in front of them displaying their title.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B \-v .B \-v

17
dwm.h
View File

@ -43,7 +43,7 @@
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMLast }; /* default atoms */ enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { ColFG, ColBG, ColLast }; /* color */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
typedef enum { typedef enum {
TopLeft, TopRight, BotLeft, BotRight TopLeft, TopRight, BotLeft, BotRight
@ -66,7 +66,6 @@ typedef struct {
int x, y, w, h; int x, y, w, h;
unsigned long norm[ColLast]; unsigned long norm[ColLast];
unsigned long sel[ColLast]; unsigned long sel[ColLast];
unsigned long status[ColLast];
Drawable drawable; Drawable drawable;
Fnt font; Fnt font;
GC gc; GC gc;
@ -78,7 +77,6 @@ struct Client {
int proto; int proto;
int x, y, w, h; int x, y, w, h;
int rx, ry, rw, rh; /* revert geometry */ int rx, ry, rw, rh; /* revert geometry */
int tx, ty, tw, th; /* title window geometry */
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
long flags; long flags;
unsigned int border; unsigned int border;
@ -88,13 +86,11 @@ struct Client {
Client *prev; Client *prev;
Client *snext; Client *snext;
Window win; Window win;
Window twin;
}; };
extern const char *tags[]; /* all tags */ extern const char *tags[]; /* all tags */
extern char stext[1024]; /* status text */ extern char stext[256]; /* status text */
extern char mtext[32]; /* mode text */ extern int bh, bmw; /* bar height, bar mode label width */
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
extern int screen, sx, sy, sw, sh; /* screen geometry */ extern int screen, sx, sy, sw, sh; /* screen geometry */
extern int wax, way, wah, waw; /* windowarea geometry */ extern int wax, way, wah, waw; /* windowarea geometry */
extern unsigned int master, nmaster; /* master percent, number of master clients */ extern unsigned int master, nmaster; /* master percent, number of master clients */
@ -110,23 +106,18 @@ extern Display *dpy;
extern Window root, barwin; extern Window root, barwin;
/* client.c */ /* client.c */
extern void ban(Client *c); /* ban c from screen */
extern void configure(Client *c); /* send synthetic configure event */ extern void configure(Client *c); /* send synthetic configure event */
extern void focus(Client *c); /* focus c, c may be NULL */ extern void focus(Client *c); /* focus c, c may be NULL */
extern Client *getclient(Window w); /* return client of w */ extern Client *getclient(Window w); /* return client of w */
extern Client *getctitle(Window w); /* return client of title window */
extern void killclient(Arg *arg); /* kill c nicely */ extern void killclient(Arg *arg); /* kill c nicely */
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/ extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
extern void resizetitle(Client *c); /* resizes c->twin correctly */
extern void updatesizehints(Client *c); /* update the size hint variables of c */ extern void updatesizehints(Client *c); /* update the size hint variables of c */
extern void updatetitle(Client *c); /* update the name of c */ extern void updatetitle(Client *c); /* update the name of c */
extern void unmanage(Client *c); /* destroy c */ extern void unmanage(Client *c); /* destroy c */
/* draw.c */ /* draw.c */
extern void drawall(void); /* draw all visible client titles and the bar */
extern void drawstatus(void); /* draw the bar */ extern void drawstatus(void); /* draw the bar */
extern void drawclient(Client *c); /* draw title and set border of c */
extern unsigned long getcolor(const char *colstr); /* return color of colstr */ extern unsigned long getcolor(const char *colstr); /* return color of colstr */
extern void setfont(const char *fontstr); /* set the font for DC */ extern void setfont(const char *fontstr); /* set the font for DC */
extern unsigned int textw(const char *text); /* return the width of text in px*/ extern unsigned int textw(const char *text); /* return the width of text in px*/
@ -152,7 +143,6 @@ extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
/* util.c */ /* util.c */
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
/* view.c */ /* view.c */
@ -168,6 +158,5 @@ extern void restack(void); /* restores z layers of all clients */
extern void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */ extern void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */ extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */ extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
extern void updatemodetext(void); /* updates mtext */
extern void view(Arg *arg); /* views the tag with arg's index */ extern void view(Arg *arg); /* views the tag with arg's index */
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */

16
event.c
View File

@ -196,7 +196,7 @@ configurerequest(XEvent *e) {
if(c->isfloat) { if(c->isfloat) {
resize(c, False, TopLeft); resize(c, False, TopLeft);
if(!isvisible(c)) if(!isvisible(c))
ban(c); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
} }
else else
arrange(); arrange();
@ -230,25 +230,21 @@ enternotify(XEvent *e) {
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return; return;
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c)) if((c = getclient(ev->window)) && isvisible(c))
focus(c); focus(c);
else if(ev->window == root) { else if(ev->window == root) {
issel = True; issel = True;
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
drawall();
} }
} }
static void static void
expose(XEvent *e) { expose(XEvent *e) {
Client *c;
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
if(ev->count == 0) { if(ev->count == 0) {
if(barwin == ev->window) if(barwin == ev->window)
drawstatus(); drawstatus();
else if((c = getctitle(ev->window)))
drawclient(c);
} }
} }
@ -274,10 +270,8 @@ static void
leavenotify(XEvent *e) { leavenotify(XEvent *e) {
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
if((ev->window == root) && !ev->same_screen) { if((ev->window == root) && !ev->same_screen)
issel = False; issel = False;
drawall();
}
} }
static void static void
@ -331,8 +325,8 @@ propertynotify(XEvent *e) {
} }
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
updatetitle(c); updatetitle(c);
resizetitle(c); if(c == sel)
drawclient(c); drawstatus();
} }
} }
} }

15
main.c
View File

@ -17,9 +17,9 @@
/* extern */ /* extern */
char stext[1024], mtext[32]; char stext[256];
Bool *seltag; Bool *seltag;
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah;
unsigned int master, nmaster, ntags, numlockmask; unsigned int master, nmaster, ntags, numlockmask;
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool running = True; Bool running = True;
@ -121,12 +121,12 @@ setup(void) {
seltag = emallocz(sizeof(Bool) * ntags); seltag = emallocz(sizeof(Bool) * ntags);
seltag[0] = True; seltag[0] = True;
/* style */ /* style */
dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
dc.norm[ColBG] = getcolor(NORMBGCOLOR); dc.norm[ColBG] = getcolor(NORMBGCOLOR);
dc.norm[ColFG] = getcolor(NORMFGCOLOR); dc.norm[ColFG] = getcolor(NORMFGCOLOR);
dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
dc.sel[ColBG] = getcolor(SELBGCOLOR); dc.sel[ColBG] = getcolor(SELBGCOLOR);
dc.sel[ColFG] = getcolor(SELFGCOLOR); dc.sel[ColFG] = getcolor(SELFGCOLOR);
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
setfont(FONT); setfont(FONT);
/* geometry */ /* geometry */
sx = sy = 0; sx = sy = 0;
@ -134,16 +134,13 @@ setup(void) {
sh = DisplayHeight(dpy, screen); sh = DisplayHeight(dpy, screen);
master = MASTER; master = MASTER;
nmaster = NMASTER; nmaster = NMASTER;
updatemodetext(); bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
/* bar */ /* bar */
bx = sx;
by = sy;
bw = sw;
dc.h = bh = dc.font.height + 2; dc.h = bh = dc.font.height + 2;
wa.override_redirect = 1; wa.override_redirect = 1;
wa.background_pixmap = ParentRelative; wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask; wa.event_mask = ButtonPressMask | ExposureMask;
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(dpy, barwin, cursor[CurNormal]); XDefineCursor(dpy, barwin, cursor[CurNormal]);

9
util.c
View File

@ -29,15 +29,6 @@ eprint(const char *errstr, ...) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
void *
erealloc(void *ptr, unsigned int size) {
void *res = realloc(ptr, size);
if(!res)
eprint("fatal: could not malloc() %u bytes\n", size);
return res;
}
void void
spawn(Arg *arg) { spawn(Arg *arg) {
static char *shell = NULL; static char *shell = NULL;

28
view.c
View File

@ -59,7 +59,7 @@ dofloat(void) {
resize(c, True, TopLeft); resize(c, True, TopLeft);
} }
else else
ban(c); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
} }
if(!sel || !isvisible(sel)) { if(!sel || !isvisible(sel)) {
for(c = stack; c && !isvisible(c); c = c->snext); for(c = stack; c && !isvisible(c); c = c->snext);
@ -109,8 +109,7 @@ dotile(void) {
i++; i++;
} }
else else
ban(c); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
if(!sel || !isvisible(sel)) { if(!sel || !isvisible(sel)) {
for(c = stack; c && !isvisible(c); c = c->snext); for(c = stack; c && !isvisible(c); c = c->snext);
focus(c); focus(c);
@ -153,7 +152,6 @@ incnmaster(Arg *arg) {
if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh)) if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
return; return;
nmaster += arg->i; nmaster += arg->i;
updatemodetext();
if(sel) if(sel)
arrange(); arrange();
else else
@ -187,27 +185,20 @@ restack(void) {
Client *c; Client *c;
XEvent ev; XEvent ev;
if(!sel) { drawstatus();
drawstatus(); if(!sel)
return; return;
} if(sel->isfloat || arrange == dofloat)
if(sel->isfloat || arrange == dofloat) {
XRaiseWindow(dpy, sel->win); XRaiseWindow(dpy, sel->win);
XRaiseWindow(dpy, sel->twin);
}
if(arrange != dofloat) { if(arrange != dofloat) {
if(!sel->isfloat) { if(!sel->isfloat)
XLowerWindow(dpy, sel->twin);
XLowerWindow(dpy, sel->win); XLowerWindow(dpy, sel->win);
}
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
if(c == sel) if(c == sel)
continue; continue;
XLowerWindow(dpy, c->twin);
XLowerWindow(dpy, c->win); XLowerWindow(dpy, c->win);
} }
} }
drawall();
XSync(dpy, False); XSync(dpy, False);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }
@ -223,7 +214,6 @@ togglefloat(Arg *arg) {
void void
togglemode(Arg *arg) { togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat; arrange = (arrange == dofloat) ? dotile : dofloat;
updatemodetext();
if(sel) if(sel)
arrange(); arrange();
else else
@ -241,12 +231,6 @@ toggleview(Arg *arg) {
arrange(); arrange();
} }
void
updatemodetext() {
snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
bmw = textw(mtext);
}
void void
view(Arg *arg) { view(Arg *arg) {
unsigned int i; unsigned int i;