Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
4606d218c3 | |||
d37d0f24e6 | |||
321e8d51ed | |||
78f4b51757 | |||
7d168a2621 | |||
931e712eac | |||
4ec04209e0 | |||
82ddba88a2 | |||
52a8cc8d46 | |||
d175df8aa3 | |||
b003a35fde | |||
df1a0f9445 | |||
5b07b85838 | |||
f320cd203b | |||
f78c16f8c6 | |||
0c5f47e720 |
2
.hgtags
2
.hgtags
@ -19,3 +19,5 @@ d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
||||
c71952fa3c7ca848ec38a6923b5c6d0e18fff431 1.8
|
||||
a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||
12deea36603da407e3f32640048846a3bd74a9ec 2.0
|
||||
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
|
||||
|
@ -9,13 +9,13 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*"
|
||||
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*"
|
||||
#define NORMBGCOLOR "#333333"
|
||||
#define NORMFGCOLOR "#dddddd"
|
||||
#define SELBGCOLOR "#333366"
|
||||
#define SELBGCOLOR "#336699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define STATUSBGCOLOR "#222222"
|
||||
#define STATUSFGCOLOR "#9999cc"
|
||||
#define STATUSFGCOLOR "#99ccff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 2.1
|
||||
VERSION = 2.3
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
37
draw.c
37
draw.c
@ -8,6 +8,16 @@
|
||||
|
||||
/* static */
|
||||
|
||||
static Bool
|
||||
isoccupied(unsigned int t)
|
||||
{
|
||||
Client *c;
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tags[t])
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
textnw(const char *text, unsigned int len) {
|
||||
XRectangle r;
|
||||
@ -20,7 +30,7 @@ textnw(const char *text, unsigned int len) {
|
||||
}
|
||||
|
||||
static void
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
@ -63,12 +73,18 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
if(highlight) {
|
||||
if(ldot) {
|
||||
r.x = dc.x + 2;
|
||||
r.y = dc.y + 2;
|
||||
r.width = r.height = (h + 2) / 4;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
if(rdot) {
|
||||
r.width = r.height = (h + 2) / 4;
|
||||
r.x = dc.x + dc.w - r.width - 2;
|
||||
r.y = dc.y + dc.h - r.height - 2;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* extern */
|
||||
@ -90,27 +106,24 @@ drawstatus(void) {
|
||||
for(i = 0; i < ntags; i++) {
|
||||
dc.w = textw(tags[i]);
|
||||
if(seltag[i])
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i));
|
||||
else
|
||||
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
||||
drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i));
|
||||
dc.x += dc.w;
|
||||
}
|
||||
dc.w = bmw;
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False);
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False, False);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bx + bw - dc.w;
|
||||
dc.x = bw - dc.w;
|
||||
if(dc.x < x) {
|
||||
dc.x = x;
|
||||
dc.w = bw - x;
|
||||
}
|
||||
drawtext(stext, dc.status, False);
|
||||
drawtext(stext, dc.status, False, False);
|
||||
if((dc.w = dc.x - x) > bh) {
|
||||
dc.x = x;
|
||||
if(sel)
|
||||
drawtext(sel->name, dc.sel, False);
|
||||
else
|
||||
drawtext(NULL, dc.norm, 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);
|
||||
XSync(dpy, False);
|
||||
@ -128,7 +141,7 @@ drawtitle(Client *c) {
|
||||
XMapWindow(dpy, c->twin);
|
||||
dc.x = dc.y = 0;
|
||||
dc.w = c->tw;
|
||||
drawtext(c->name, dc.norm, False);
|
||||
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);
|
||||
}
|
||||
|
6
dwm.1
6
dwm.1
@ -20,8 +20,10 @@ tags. Selecting certain tags displays all windows with these tags.
|
||||
.P
|
||||
dwm contains a small status bar which displays all available tags, the mode,
|
||||
the title of the focused window, and the text read from standard input. The
|
||||
selected tags are highlighted with a different color, the tags of the focused
|
||||
window are highlighted with a small point.
|
||||
selected tags are indicated with a different color. The tags of the focused
|
||||
window are indicated with a small point in the top left corner. The tags which
|
||||
are applied by any client are indicated with a small point in the bottom
|
||||
right corner.
|
||||
.P
|
||||
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.
|
||||
|
3
dwm.h
3
dwm.h
@ -82,7 +82,7 @@ struct Client {
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int grav;
|
||||
long flags;
|
||||
unsigned int border, weight;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
@ -96,6 +96,7 @@ extern const char *tags[]; /* all tags */
|
||||
extern char stext[1024]; /* status text */
|
||||
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
|
||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||
|
16
event.c
16
event.c
@ -48,14 +48,14 @@ movemouse(Client *c) {
|
||||
XSync(dpy, False);
|
||||
c->x = ocx + (ev.xmotion.x - x1);
|
||||
c->y = ocy + (ev.xmotion.y - y1);
|
||||
if(abs(sx + c->x) < SNAP)
|
||||
c->x = sx;
|
||||
else if(abs((sx + sw) - (c->x + c->w)) < SNAP)
|
||||
c->x = sw - c->w - 2 * BORDERPX;
|
||||
if(abs((sy + bh) - c->y) < SNAP)
|
||||
c->y = sy + bh;
|
||||
else if(abs((sy + sh) - (c->y + c->h)) < SNAP)
|
||||
c->y = sh - c->h - 2 * BORDERPX;
|
||||
if(abs(wax + c->x) < SNAP)
|
||||
c->x = wax;
|
||||
else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * BORDERPX;
|
||||
if(abs(way - c->y) < SNAP)
|
||||
c->y = way;
|
||||
else if(abs((way + wah) - (c->y + c->h)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * BORDERPX;
|
||||
resize(c, False, TopLeft);
|
||||
break;
|
||||
}
|
||||
|
10
main.c
10
main.c
@ -18,7 +18,7 @@
|
||||
|
||||
char stext[1024];
|
||||
Bool *seltag;
|
||||
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh;
|
||||
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, ntags, numlockmask;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
@ -130,7 +130,8 @@ setup(void) {
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
master = MASTER;
|
||||
/* bar */
|
||||
bx = by = 0;
|
||||
bx = sx;
|
||||
by = sy;
|
||||
bw = sw;
|
||||
dc.h = bh = dc.font.height + 2;
|
||||
wa.override_redirect = 1;
|
||||
@ -142,6 +143,11 @@ setup(void) {
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
XMapRaised(dpy, barwin);
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* windowarea */
|
||||
wax = sx;
|
||||
way = sy + bh;
|
||||
wah = sh - bh;
|
||||
waw = sw;
|
||||
/* pixmap for everything */
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
|
3
tag.c
3
tag.c
@ -104,7 +104,6 @@ settags(Client *c, Client *trans) {
|
||||
if(!matched)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = seltag[i];
|
||||
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
||||
}
|
||||
|
||||
void
|
||||
@ -116,7 +115,6 @@ tag(Arg *arg) {
|
||||
for(i = 0; i < ntags; i++)
|
||||
sel->tags[i] = False;
|
||||
sel->tags[arg->i] = True;
|
||||
sel->weight = arg->i;
|
||||
arrange();
|
||||
}
|
||||
|
||||
@ -130,6 +128,5 @@ toggletag(Arg *arg) {
|
||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||
if(i == ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
sel->weight = (i == ntags) ? arg->i : i;
|
||||
arrange();
|
||||
}
|
||||
|
83
view.c
83
view.c
@ -5,42 +5,12 @@
|
||||
|
||||
/* static */
|
||||
|
||||
static Client *
|
||||
minclient(void) {
|
||||
Client *c, *min;
|
||||
|
||||
if((clients && clients->isfloat) || arrange == dofloat)
|
||||
return clients; /* don't touch floating order */
|
||||
for(min = c = clients; c; c = c->next)
|
||||
if(c->weight < min->weight)
|
||||
min = c;
|
||||
return min;
|
||||
}
|
||||
|
||||
static Client *
|
||||
nexttiled(Client *c) {
|
||||
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
reorder(void) {
|
||||
Client *c, *newclients, *tail;
|
||||
|
||||
newclients = tail = NULL;
|
||||
while((c = minclient())) {
|
||||
detach(c);
|
||||
if(tail) {
|
||||
c->prev = tail;
|
||||
tail->next = c;
|
||||
tail = c;
|
||||
}
|
||||
else
|
||||
tail = newclients = c;
|
||||
}
|
||||
clients = newclients;
|
||||
}
|
||||
|
||||
static void
|
||||
togglemax(Client *c) {
|
||||
XEvent ev;
|
||||
@ -49,10 +19,10 @@ togglemax(Client *c) {
|
||||
return;
|
||||
|
||||
if((c->ismax = !c->ismax)) {
|
||||
c->rx = c->x; c->x = sx;
|
||||
c->ry = c->y; c->y = bh;
|
||||
c->rw = c->w; c->w = sw - 2 * BORDERPX;
|
||||
c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
|
||||
c->rx = c->x; c->x = wax;
|
||||
c->ry = c->y; c->y = way;
|
||||
c->rw = c->w; c->w = waw - 2 * BORDERPX;
|
||||
c->rh = c->h; c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else {
|
||||
c->x = c->rx;
|
||||
@ -99,17 +69,13 @@ dofloat(void) {
|
||||
|
||||
void
|
||||
dotile(void) {
|
||||
unsigned int i, n, mpx, stackw, stackh, th;
|
||||
unsigned int i, n, mpx, stackw, th;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
mpx = (sw * master) / 1000;
|
||||
stackw = sw - mpx;
|
||||
stackh = sh - bh;
|
||||
th = stackh;
|
||||
if(n > 1)
|
||||
th /= (n - 1);
|
||||
mpx = (waw * master) / 1000;
|
||||
stackw = waw - mpx;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
@ -118,28 +84,26 @@ dotile(void) {
|
||||
continue;
|
||||
}
|
||||
c->ismax = False;
|
||||
c->x = sx;
|
||||
c->y = sy + bh;
|
||||
c->x = wax;
|
||||
c->y = way;
|
||||
if(n == 1) { /* only 1 window */
|
||||
c->w = sw - 2 * BORDERPX;
|
||||
c->h = sh - 2 * BORDERPX - bh;
|
||||
c->w = waw - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else if(i == 0) { /* master window */
|
||||
c->w = mpx - 2 * BORDERPX;
|
||||
c->h = sh - bh - 2 * BORDERPX;
|
||||
c->w = waw - stackw - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
th = wah / (n - 1);
|
||||
}
|
||||
else { /* tile window */
|
||||
c->x += mpx;
|
||||
c->w = stackw - 2 * BORDERPX;
|
||||
if(th > bh) {
|
||||
c->y = sy + (i - 1) * th + bh;
|
||||
if(i + 1 == n)
|
||||
c->h = sh - c->y - 2 * BORDERPX;
|
||||
else
|
||||
c->h = th - 2 * BORDERPX;
|
||||
c->y = way + (i - 1) * th;
|
||||
c->h = th - 2 * BORDERPX;
|
||||
}
|
||||
else /* fallback if th < bh */
|
||||
c->h = stackh - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
i++;
|
||||
@ -196,9 +160,13 @@ isvisible(Client *c) {
|
||||
|
||||
void
|
||||
resizemaster(Arg *arg) {
|
||||
if(master + arg->i > 950 || master + arg->i < 50)
|
||||
return;
|
||||
master += arg->i;
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(master + arg->i > 950 || master + arg->i < 50)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
arrange();
|
||||
}
|
||||
|
||||
@ -249,7 +217,6 @@ toggleview(Arg *arg) {
|
||||
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||
if(i == ntags)
|
||||
seltag[arg->i] = True; /* cannot toggle last view */
|
||||
reorder();
|
||||
arrange();
|
||||
}
|
||||
|
||||
@ -260,7 +227,6 @@ view(Arg *arg) {
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = False;
|
||||
seltag[arg->i] = True;
|
||||
reorder();
|
||||
arrange();
|
||||
}
|
||||
|
||||
@ -270,7 +236,6 @@ viewall(Arg *arg) {
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = True;
|
||||
reorder();
|
||||
arrange();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user