Compare commits
204 Commits
Author | SHA1 | Date | |
---|---|---|---|
01d13b0c49 | |||
f15f45a9f8 | |||
1b2e149cb4 | |||
6136640ec9 | |||
95d8423823 | |||
de6411c338 | |||
e316cf53f6 | |||
c107db57db | |||
d39d00057c | |||
26157e6973 | |||
6d22782e8f | |||
1836b6740d | |||
924a088812 | |||
bab575c868 | |||
daae3bba50 | |||
05fbbbd8dc | |||
4c368bcd24 | |||
9927b9e642 | |||
1b492dffc8 | |||
140be1b4b3 | |||
79259acc12 | |||
5a3bea2d69 | |||
30d928591d | |||
70a3e62257 | |||
6828fba7a0 | |||
aa1bda8164 | |||
157ea539a2 | |||
c3c94c0e0a | |||
9d73909075 | |||
016c54196e | |||
5056bb952d | |||
8a6679b3b4 | |||
7b6d5ff298 | |||
846850914d | |||
4e6c513ac2 | |||
db9cda6a7d | |||
a50b15a9e9 | |||
0a25fe9188 | |||
2dd5212a79 | |||
00e95e1f38 | |||
0a0759132c | |||
5cf362c7d0 | |||
413be1112a | |||
8233dc8568 | |||
afa8b3bcd9 | |||
c518345f40 | |||
afe6ac9923 | |||
e995c1b532 | |||
e36929292e | |||
03128f78df | |||
7d4a5e654c | |||
41ba7a7984 | |||
aa471f2d65 | |||
d37dfa1bed | |||
9f35cc52fe | |||
f1fe19bc2b | |||
b55bd709ee | |||
9833610356 | |||
de7fc0011e | |||
2e0c767d74 | |||
a5379e901c | |||
a039d51d5f | |||
60b3dceccf | |||
c2ac851b90 | |||
c976bc6c2c | |||
2e834e941f | |||
77e5f3167c | |||
7e597ae204 | |||
c39df91ab9 | |||
af1158d105 | |||
b739721d9e | |||
7711ab6707 | |||
d370c32f69 | |||
d6a6eca71d | |||
39ffc18635 | |||
3e972ec84d | |||
b5159dfd2f | |||
07c2659806 | |||
dc83b9e988 | |||
8b4bc8270a | |||
0ff80653d3 | |||
352e1b4c81 | |||
aa13727067 | |||
595028614b | |||
6a3ae5e26a | |||
8c334ee078 | |||
f60fe2a4f9 | |||
b112257bf2 | |||
eb88adcd8a | |||
950a1ab5af | |||
1b9fe55025 | |||
2272df9d31 | |||
08d85d6d66 | |||
b43989207a | |||
2eebebf262 | |||
8c1fffe106 | |||
5e9acbc952 | |||
a420ceab50 | |||
0e1c649dca | |||
67c2124fa9 | |||
a635743c6d | |||
b5c2412d84 | |||
ad2e77d635 | |||
a20b10d01f | |||
4cc0551948 | |||
56130c3689 | |||
14f7380308 | |||
727449d1e7 | |||
80bf2aa559 | |||
b9cd0c4331 | |||
f77a87137c | |||
65dfe8fdce | |||
e3bb595d77 | |||
a1682b8927 | |||
24d91e3b8a | |||
ce04a66528 | |||
df74b26e5d | |||
b6ad663f87 | |||
ee31e38dc7 | |||
442334641e | |||
dfa5ea6360 | |||
3e06edeb5d | |||
78b050c13c | |||
4ad20ffc2c | |||
57e6e3bb80 | |||
19da197f58 | |||
666fae97e6 | |||
823fb1118a | |||
db1d62e184 | |||
d26ffc7fa3 | |||
0f3acce042 | |||
9eef9f7b02 | |||
aff4c787f4 | |||
fe3dfbbe90 | |||
2ffdc1936c | |||
0fe52c63ea | |||
28a52197c4 | |||
2c0d1cc87b | |||
375a251d16 | |||
d4b7a9a373 | |||
4d67199a4b | |||
95766d6241 | |||
4cb78a170c | |||
2c66b422e7 | |||
e571de83e9 | |||
4bb89e2cb1 | |||
349cadacf6 | |||
292ccc4c43 | |||
d7413ffd2d | |||
50729a2e73 | |||
a3e3f0b9ed | |||
45aea23355 | |||
975b459c17 | |||
2b35faee06 | |||
84818bdbb5 | |||
895902b57a | |||
7d4184dc5c | |||
8278f0a6be | |||
d3969634ac | |||
735ca9ccd6 | |||
4ee661d908 | |||
9fce8215b7 | |||
6521c2dd41 | |||
9ee9ce7e14 | |||
9d39da6452 | |||
0228dcd58f | |||
3d35ea99bb | |||
0680c76a6f | |||
c3e5f5cc9a | |||
1c620d27d8 | |||
fde45ebed8 | |||
4bd0d33f57 | |||
00255728aa | |||
4b0328f209 | |||
30561a0161 | |||
a4c4998c8b | |||
8e053b6476 | |||
b79b5facb1 | |||
c53f0fca91 | |||
c225e1afc2 | |||
92e55c7c53 | |||
c86f131681 | |||
e943234d09 | |||
9fc24e371b | |||
cac467d52c | |||
04f17d2669 | |||
dff15a02f7 | |||
42277b1110 | |||
095f9e143e | |||
9fbb2ebb90 | |||
dbcf87ce76 | |||
4250c26e9b | |||
e48de30516 | |||
1f0060caa3 | |||
c732cc90ab | |||
4e2c5b5f25 | |||
d9386a0c07 | |||
66e16c92d3 | |||
6a8e176df1 | |||
632c7f3410 | |||
045f1840e0 | |||
45d16d090b | |||
525c5ff4d8 | |||
5952157c3b |
8
.hgtags
8
.hgtags
@ -4,3 +4,11 @@ d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
|||||||
eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
||||||
22213b9a2114167ee8ba019a012e27da0422a61a 0.5
|
22213b9a2114167ee8ba019a012e27da0422a61a 0.5
|
||||||
c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
||||||
|
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
||||||
|
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
||||||
|
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
||||||
|
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||||
|
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||||
|
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||||
|
6413ea66b1c2496cfc2173fe58df67cb965eb1da 1.3
|
||||||
|
dd44dc937e8b0a46abf1a15a333dba5304e4fe89 1.3
|
||||||
|
1
LICENSE
1
LICENSE
@ -1,6 +1,7 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
(C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
(C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
|
(C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
10
Makefile
10
Makefile
@ -3,23 +3,23 @@
|
|||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = client.c draw.c event.c main.c tag.c util.c
|
SRC = client.c draw.c event.c main.c tag.c util.c view.c
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
all: options dwm
|
all: options dwm
|
||||||
@echo finished
|
|
||||||
|
|
||||||
options:
|
options:
|
||||||
@echo dwm build options:
|
@echo dwm build options:
|
||||||
@echo "CFLAGS = ${CFLAGS}"
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
@echo "LDFLAGS = ${LDFLAGS}"
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
@echo "CC = ${CC}"
|
@echo "CC = ${CC}"
|
||||||
|
@echo "LD = ${LD}"
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo CC $<
|
@echo CC $<
|
||||||
@${CC} -c ${CFLAGS} $<
|
@${CC} -c ${CFLAGS} $<
|
||||||
|
|
||||||
${OBJ}: dwm.h config.h
|
${OBJ}: dwm.h config.h config.mk
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
@echo creating $@ from config.default.h
|
@echo creating $@ from config.default.h
|
||||||
@ -27,7 +27,7 @@ config.h:
|
|||||||
|
|
||||||
dwm: ${OBJ}
|
dwm: ${OBJ}
|
||||||
@echo LD $@
|
@echo LD $@
|
||||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
@${LD} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
@strip $@
|
@strip $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -50,7 +50,7 @@ install: all
|
|||||||
@chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
@chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||||
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
||||||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
@cp -f dwm.1 ${DESTDIR}${MANPREFIX}/man1
|
@sed 's/VERSION/${VERSION}/g' < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
2
README
2
README
@ -1,6 +1,6 @@
|
|||||||
dwm - dynamic window manager
|
dwm - dynamic window manager
|
||||||
----------------------------
|
----------------------------
|
||||||
dwm is an extremely fast, small, and dynamic X11 window manager.
|
dwm is an extremely fast, small, and dynamic window manager for X.
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
|
274
client.c
274
client.c
@ -10,24 +10,57 @@
|
|||||||
|
|
||||||
/* static functions */
|
/* static functions */
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabbuttons(Client *c, Bool focus)
|
||||||
|
{
|
||||||
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
|
|
||||||
|
if(focus) {
|
||||||
|
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
|
||||||
|
XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
|
||||||
|
XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
|
||||||
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
resizetitle(Client *c)
|
resizetitle(Client *c)
|
||||||
{
|
{
|
||||||
int i;
|
c->tw = textw(c->name);
|
||||||
|
|
||||||
c->tw = 0;
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
if(c->tags[i])
|
|
||||||
c->tw += textw(tags[i]);
|
|
||||||
c->tw += textw(c->name);
|
|
||||||
if(c->tw > c->w)
|
if(c->tw > c->w)
|
||||||
c->tw = c->w + 2;
|
c->tw = c->w + 2;
|
||||||
c->tx = c->x + c->w - c->tw + 2;
|
c->tx = c->x + c->w - c->tw + 2;
|
||||||
c->ty = c->y;
|
c->ty = c->y;
|
||||||
if(c->tags[tsel])
|
if(isvisible(c))
|
||||||
XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
|
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
|
||||||
else
|
else
|
||||||
XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,62 +76,35 @@ void
|
|||||||
ban(Client *c)
|
ban(Client *c)
|
||||||
{
|
{
|
||||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
Client *old = sel;
|
Client *old;
|
||||||
XEvent ev;
|
|
||||||
|
|
||||||
sel = c;
|
if(!issel)
|
||||||
if(old && old != c)
|
|
||||||
drawtitle(old);
|
|
||||||
drawtitle(c);
|
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
|
||||||
XSync(dpy, False);
|
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
focusnext(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(!sel)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(sel->ismax)
|
|
||||||
togglemax(NULL);
|
|
||||||
|
|
||||||
if(!(c = getnext(sel->next)))
|
|
||||||
c = getnext(clients);
|
|
||||||
if(c) {
|
|
||||||
higher(c);
|
|
||||||
focus(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
focusprev(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
sel = c;
|
||||||
|
else if(sel != c) {
|
||||||
if(sel->ismax)
|
if(maximized)
|
||||||
togglemax(NULL);
|
togglemax(NULL);
|
||||||
|
old = sel;
|
||||||
if(!(c = getprev(sel->prev))) {
|
sel = c;
|
||||||
for(c = clients; c && c->next; c = c->next);
|
if(old) {
|
||||||
c = getprev(c);
|
grabbuttons(old, False);
|
||||||
|
drawtitle(old);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(c) {
|
if(c) {
|
||||||
higher(c);
|
grabbuttons(c, True);
|
||||||
focus(c);
|
drawtitle(c);
|
||||||
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
@ -118,7 +124,7 @@ getctitle(Window w)
|
|||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
if(c->title == w)
|
if(c->twin == w)
|
||||||
return c;
|
return c;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -178,13 +184,6 @@ gravitate(Client *c, Bool invert)
|
|||||||
c->y += dy;
|
c->y += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
higher(Client *c)
|
|
||||||
{
|
|
||||||
XRaiseWindow(dpy, c->win);
|
|
||||||
XRaiseWindow(dpy, c->title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
killclient(Arg *arg)
|
killclient(Arg *arg)
|
||||||
{
|
{
|
||||||
@ -196,17 +195,11 @@ killclient(Arg *arg)
|
|||||||
XKillClient(dpy, sel->win);
|
XKillClient(dpy, sel->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
lower(Client *c)
|
|
||||||
{
|
|
||||||
XLowerWindow(dpy, c->title);
|
|
||||||
XLowerWindow(dpy, c->win);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
Client *c;
|
unsigned int i;
|
||||||
|
Client *c, *tc;
|
||||||
Window trans;
|
Window trans;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
|
|
||||||
@ -222,8 +215,14 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
c->border = 0;
|
c->border = 0;
|
||||||
setsize(c);
|
setsize(c);
|
||||||
|
|
||||||
|
if(c->x + c->w + 2 > sw)
|
||||||
|
c->x = sw - c->w - 2;
|
||||||
|
if(c->x < 0)
|
||||||
|
c->x = 0;
|
||||||
|
if(c->y + c->h + 2 > sh)
|
||||||
|
c->y = sh - c->h - 2;
|
||||||
if(c->h != sh && c->y < bh)
|
if(c->h != sh && c->y < bh)
|
||||||
c->y = c->ty = bh;
|
c->y = bh;
|
||||||
|
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
@ -233,56 +232,34 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
twa.background_pixmap = ParentRelative;
|
twa.background_pixmap = ParentRelative;
|
||||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||||
|
|
||||||
c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
|
grabbuttons(c, False);
|
||||||
|
if((tc = getclient(trans))) /* inherit tags */
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
c->tags[i] = tc->tags[i];
|
||||||
|
else
|
||||||
|
settags(c);
|
||||||
|
if(!c->isfloat)
|
||||||
|
c->isfloat = trans
|
||||||
|
|| (c->maxw && c->minw &&
|
||||||
|
c->maxw == c->minw && c->maxh == c->minh);
|
||||||
|
|
||||||
if(clients)
|
if(clients)
|
||||||
clients->prev = c;
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
|
|
||||||
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
|
|
||||||
XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
|
|
||||||
XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
|
|
||||||
settags(c);
|
|
||||||
if(!c->isfloat)
|
|
||||||
c->isfloat = trans
|
|
||||||
|| (c->maxw && c->minw &&
|
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
|
||||||
settitle(c);
|
settitle(c);
|
||||||
arrange(NULL);
|
ban(c);
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
/* mapping the window now prevents flicker */
|
XMapWindow(dpy, c->twin);
|
||||||
XMapRaised(dpy, c->win);
|
if(isvisible(c))
|
||||||
XMapRaised(dpy, c->title);
|
|
||||||
if(c->tags[tsel])
|
|
||||||
focus(c);
|
focus(c);
|
||||||
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -290,7 +267,6 @@ resize(Client *c, Bool sizehints, Corner sticky)
|
|||||||
{
|
{
|
||||||
int bottom = c->y + c->h;
|
int bottom = c->y + c->h;
|
||||||
int right = c->x + c->w;
|
int right = c->x + c->w;
|
||||||
/*XConfigureEvent e;*/
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
if(sizehints) {
|
if(sizehints) {
|
||||||
@ -307,10 +283,6 @@ resize(Client *c, Bool sizehints, Corner sticky)
|
|||||||
if(c->maxh && c->h > c->maxh)
|
if(c->maxh && c->h > c->maxh)
|
||||||
c->h = c->maxh;
|
c->h = c->maxh;
|
||||||
}
|
}
|
||||||
if(c->x > right) /* might happen on restart */
|
|
||||||
c->x = right - c->w;
|
|
||||||
if(c->y > bottom)
|
|
||||||
c->y = bottom - c->h;
|
|
||||||
if(sticky == TopRight || sticky == BotRight)
|
if(sticky == TopRight || sticky == BotRight)
|
||||||
c->x = right - c->w;
|
c->x = right - c->w;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
if(sticky == BotLeft || sticky == BotRight)
|
||||||
@ -400,12 +372,13 @@ void
|
|||||||
togglemax(Arg *arg)
|
togglemax(Arg *arg)
|
||||||
{
|
{
|
||||||
int ox, oy, ow, oh;
|
int ox, oy, ow, oh;
|
||||||
|
Client *c;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((sel->ismax = !sel->ismax)) {
|
if((maximized = !maximized)) {
|
||||||
ox = sel->x;
|
ox = sel->x;
|
||||||
oy = sel->y;
|
oy = sel->y;
|
||||||
ow = sel->w;
|
ow = sel->w;
|
||||||
@ -415,8 +388,11 @@ togglemax(Arg *arg)
|
|||||||
sel->w = sw - 2;
|
sel->w = sw - 2;
|
||||||
sel->h = sh - 2 - bh;
|
sel->h = sh - 2 - bh;
|
||||||
|
|
||||||
higher(sel);
|
restack();
|
||||||
resize(sel, False, TopLeft);
|
for(c = getnext(clients); c; c = getnext(c->next))
|
||||||
|
if(c != sel)
|
||||||
|
ban(c);
|
||||||
|
resize(sel, arrange == dofloat, TopLeft);
|
||||||
|
|
||||||
sel->x = ox;
|
sel->x = ox;
|
||||||
sel->y = oy;
|
sel->y = oy;
|
||||||
@ -424,32 +400,31 @@ togglemax(Arg *arg)
|
|||||||
sel->h = oh;
|
sel->h = oh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
resize(sel, False, TopLeft);
|
arrange(NULL);
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unmanage(Client *c)
|
unmanage(Client *c)
|
||||||
{
|
{
|
||||||
|
Client *tc, *fc;
|
||||||
|
Window trans;
|
||||||
XGrabServer(dpy);
|
XGrabServer(dpy);
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
|
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
detach(c);
|
||||||
XDestroyWindow(dpy, c->title);
|
|
||||||
|
|
||||||
if(c->prev)
|
|
||||||
c->prev->next = c->next;
|
|
||||||
if(c->next)
|
|
||||||
c->next->prev = c->prev;
|
|
||||||
if(c == clients)
|
|
||||||
clients = c->next;
|
|
||||||
if(sel == c) {
|
if(sel == c) {
|
||||||
sel = getnext(c->next);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
if(!sel)
|
if(trans && (tc = getclient(trans)) && isvisible(tc))
|
||||||
sel = getprev(c->prev);
|
fc = tc;
|
||||||
if(!sel)
|
else
|
||||||
sel = clients;
|
fc = getnext(clients);
|
||||||
|
focus(fc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
|
XDestroyWindow(dpy, c->twin);
|
||||||
|
|
||||||
free(c->tags);
|
free(c->tags);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
@ -457,35 +432,4 @@ unmanage(Client *c)
|
|||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
if(sel)
|
|
||||||
focus(sel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
zoom(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(!sel || (arrange != dotile) || sel->isfloat)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(sel == getnext(clients)) {
|
|
||||||
if((c = getnext(sel->next)))
|
|
||||||
sel = c;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pop */
|
|
||||||
if(sel->prev)
|
|
||||||
sel->prev->next = sel->next;
|
|
||||||
if(sel->next)
|
|
||||||
sel->next->prev = sel->prev;
|
|
||||||
sel->prev = NULL;
|
|
||||||
if(clients)
|
|
||||||
clients->prev = sel;
|
|
||||||
sel->next = clients;
|
|
||||||
clients = sel;
|
|
||||||
arrange(NULL);
|
|
||||||
focus(sel);
|
|
||||||
}
|
}
|
||||||
|
83
config.arg.h
83
config.arg.h
@ -4,56 +4,61 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "fnord", "dev", "net", "work", "misc", NULL };
|
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define DEFTAG 1 /* index */
|
#define FLOATSYMBOL "><>"
|
||||||
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
#define TILESYMBOL "[]="
|
||||||
#define BGCOLOR "#0a2c2d"
|
|
||||||
#define FGCOLOR "#ddeeee"
|
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
||||||
#define BORDERCOLOR "#176164"
|
#define SELBGCOLOR "#333366"
|
||||||
|
#define SELFGCOLOR "#eeeeee"
|
||||||
|
#define NORMBGCOLOR "#333333"
|
||||||
|
#define NORMFGCOLOR "#dddddd"
|
||||||
|
#define STATUSBGCOLOR "#222222"
|
||||||
|
#define STATUSFGCOLOR "#9999cc"
|
||||||
|
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define NUMLOCKMASK Mod2Mask
|
|
||||||
#define MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function arguments */ \
|
||||||
{ MODKEY, XK_0, view, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||||
{ MODKEY, XK_1, view, { .i = 1 } }, \
|
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 2 } }, \
|
{ MODKEY, XK_p, spawn, \
|
||||||
{ MODKEY, XK_3, view, { .i = 3 } }, \
|
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
||||||
{ MODKEY, XK_4, view, { .i = 4 } }, \
|
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
|
||||||
{ MODKEY, XK_h, viewprev, { 0 } }, \
|
"done | sort -u | dmenu)\" && exec \"$exe\"" } }, \
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_l, viewnext, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||||
{ MODKEY, XK_p, spawn, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ .cmd = "exec `ls -lL /usr/bin /usr/local/bin 2>/dev/null |" \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
" awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | dmenu`" } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_0, appendtag, { .i = 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask, XK_1, appendtag, { .i = 1 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||||
{ MODKEY|ControlMask, XK_2, appendtag, { .i = 2 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask, XK_3, appendtag, { .i = 3 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_4, appendtag, { .i = 4 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = 0 } }, \
|
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = 1 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = 2 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = 3 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_4, replacetag, { .i = 5 } }, \
|
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||||
{ .cmd = "exec urxvt -tr +sb -bg black -fg white -cr white " \
|
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||||
"-fn '-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*'" } }, \
|
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RULES \
|
#define RULES \
|
||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "net", False }, \
|
{ "Firefox.*", "net", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True}, \
|
||||||
{ "MPlayer.*", NULL, True}, \
|
{ "MPlayer.*", NULL, True}, \
|
||||||
|
@ -4,51 +4,62 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "0", "1", "2", "3", "4", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define DEFTAG 1 /* index */
|
#define FLOATSYMBOL "~"
|
||||||
|
#define TILESYMBOL "#"
|
||||||
|
|
||||||
#define FONT "fixed"
|
#define FONT "fixed"
|
||||||
#define BGCOLOR "#666699"
|
#define SELBGCOLOR "#666699"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define BORDERCOLOR "#9999CC"
|
#define NORMBGCOLOR "#333366"
|
||||||
|
#define NORMFGCOLOR "#cccccc"
|
||||||
|
#define STATUSBGCOLOR "#dddddd"
|
||||||
|
#define STATUSFGCOLOR "#222222"
|
||||||
|
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define NUMLOCKMASK Mod2Mask
|
|
||||||
#define MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function arguments */ \
|
||||||
{ MODKEY, XK_0, view, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 1 } }, \
|
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 3 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_4, view, { .i = 4 } }, \
|
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||||
{ MODKEY, XK_h, viewprev, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
{ MODKEY, XK_l, viewnext, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask, XK_0, appendtag, { .i = 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||||
{ MODKEY|ControlMask, XK_1, appendtag, { .i = 1 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask, XK_2, appendtag, { .i = 2 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||||
{ MODKEY|ControlMask, XK_3, appendtag, { .i = 3 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_4, appendtag, { .i = 4 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = 0 } }, \
|
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = 1 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = 2 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = 3 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_4, replacetag, { .i = 4 } }, \
|
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||||
|
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Query class:instance:title for regex matching info with following command:
|
||||||
|
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */
|
||||||
#define RULES \
|
#define RULES \
|
||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "2", False }, \
|
{ "Firefox.*", "2", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True}, \
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 0.7
|
VERSION = 1.3
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ X11INC = /usr/X11R6/include
|
|||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I/usr/lib -I${X11INC}
|
INCS = -I. -I/usr/include -I${X11INC}
|
||||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
|
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
@ -20,5 +20,6 @@ LDFLAGS = ${LIBS}
|
|||||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||||
#LDFLAGS = -g ${LIBS}
|
#LDFLAGS = -g ${LIBS}
|
||||||
|
|
||||||
# compiler
|
# compiler and linker
|
||||||
CC = cc
|
CC = cc
|
||||||
|
LD = ${CC}
|
||||||
|
120
draw.c
120
draw.c
@ -9,26 +9,6 @@
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static void
|
|
||||||
drawborder(void)
|
|
||||||
{
|
|
||||||
XPoint points[5];
|
|
||||||
|
|
||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
|
||||||
XSetForeground(dpy, dc.gc, dc.border);
|
|
||||||
points[0].x = dc.x;
|
|
||||||
points[0].y = dc.y;
|
|
||||||
points[1].x = dc.w - 1;
|
|
||||||
points[1].y = 0;
|
|
||||||
points[2].x = 0;
|
|
||||||
points[2].y = dc.h - 1;
|
|
||||||
points[3].x = -(dc.w - 1);
|
|
||||||
points[3].y = 0;
|
|
||||||
points[4].x = 0;
|
|
||||||
points[4].y = -(dc.h - 1);
|
|
||||||
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
textnw(const char *text, unsigned int len)
|
textnw(const char *text, unsigned int len)
|
||||||
{
|
{
|
||||||
@ -42,25 +22,22 @@ textnw(const char *text, unsigned int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, Bool invert, Bool border)
|
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
unsigned int len;
|
unsigned int len, olen;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||||
|
|
||||||
XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
|
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
|
|
||||||
w = 0;
|
|
||||||
if(border)
|
|
||||||
drawborder();
|
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
len = strlen(text);
|
w = 0;
|
||||||
|
olen = len = strlen(text);
|
||||||
if(len >= sizeof(buf))
|
if(len >= sizeof(buf))
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof(buf) - 1;
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
@ -73,21 +50,32 @@ drawtext(const char *text, Bool invert, Bool border)
|
|||||||
/* shorten text if necessary */
|
/* shorten text if necessary */
|
||||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||||
buf[--len] = 0;
|
buf[--len] = 0;
|
||||||
|
if(len < olen) {
|
||||||
|
if(len > 1)
|
||||||
|
buf[len - 1] = '.';
|
||||||
|
if(len > 2)
|
||||||
|
buf[len - 2] = '.';
|
||||||
|
if(len > 3)
|
||||||
|
buf[len - 3] = '.';
|
||||||
|
}
|
||||||
|
|
||||||
if(w > dc.w)
|
if(w > dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
|
gcv.foreground = col[ColFG];
|
||||||
gcv.foreground = invert ? dc.bg : dc.fg;
|
|
||||||
gcv.background = invert ? dc.fg : dc.bg;
|
|
||||||
if(dc.font.set) {
|
if(dc.font.set) {
|
||||||
XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
|
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||||
XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc,
|
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||||
x, y, buf, len);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gcv.font = dc.font.xfont->fid;
|
gcv.font = dc.font.xfont->fid;
|
||||||
XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
|
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||||
XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||||
|
}
|
||||||
|
if(highlight) {
|
||||||
|
r.x = dc.x + 2;
|
||||||
|
r.y = dc.y + 2;
|
||||||
|
r.width = r.height = 3;
|
||||||
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,28 +95,36 @@ void
|
|||||||
drawstatus()
|
drawstatus()
|
||||||
{
|
{
|
||||||
int i, x;
|
int i, x;
|
||||||
Bool istile = arrange == dotile;
|
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
dc.w = bw;
|
|
||||||
drawtext(NULL, !istile, False);
|
|
||||||
|
|
||||||
dc.w = 0;
|
|
||||||
for(i = 0; i < ntags; i++) {
|
for(i = 0; i < ntags; i++) {
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(tags[i]);
|
dc.w = textw(tags[i]);
|
||||||
if(istile)
|
if(seltag[i])
|
||||||
drawtext(tags[i], (i == tsel), True);
|
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||||
else
|
else
|
||||||
drawtext(tags[i], (i != tsel), True);
|
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
||||||
|
dc.x += dc.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dc.w = bmw;
|
||||||
|
drawtext(arrange == dotile ? TILESYMBOL : FLOATSYMBOL, dc.status, False);
|
||||||
|
|
||||||
x = dc.x + dc.w;
|
x = dc.x + dc.w;
|
||||||
dc.w = textw(stext);
|
dc.w = textw(stext);
|
||||||
dc.x = bx + bw - dc.w;
|
dc.x = bx + bw - dc.w;
|
||||||
drawtext(stext, !istile, False);
|
if(dc.x < x) {
|
||||||
if(sel && ((dc.w = dc.x - x) >= bh)) {
|
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
drawtext(sel->name, istile, True);
|
dc.w = bw - x;
|
||||||
|
}
|
||||||
|
drawtext(stext, dc.status, 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);
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -137,33 +133,19 @@ drawstatus()
|
|||||||
void
|
void
|
||||||
drawtitle(Client *c)
|
drawtitle(Client *c)
|
||||||
{
|
{
|
||||||
int i;
|
if(c == sel && issel) {
|
||||||
Bool istile = arrange == dotile;
|
|
||||||
|
|
||||||
if(c == sel) {
|
|
||||||
drawstatus();
|
drawstatus();
|
||||||
XUnmapWindow(dpy, c->title);
|
XUnmapWindow(dpy, c->twin);
|
||||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.bg);
|
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||||
XMapWindow(dpy, c->title);
|
XMapWindow(dpy, c->twin);
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
|
dc.w = c->tw;
|
||||||
dc.w = 0;
|
drawtext(c->name, dc.norm, False);
|
||||||
for(i = 0; i < ntags; i++) {
|
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||||
if(c->tags[i]) {
|
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(tags[i]);
|
|
||||||
drawtext(tags[i], !istile, True);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(c->name);
|
|
||||||
drawtext(c->name, !istile, True);
|
|
||||||
XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
153
dwm.1
153
dwm.1
@ -1,4 +1,4 @@
|
|||||||
.TH DWM 1 dwm-0.7
|
.TH DWM 1 dwm-VERSION
|
||||||
.SH NAME
|
.SH NAME
|
||||||
dwm \- dynamic window manager
|
dwm \- dynamic window manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -6,7 +6,7 @@ dwm \- dynamic window manager
|
|||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B dwm
|
.B dwm
|
||||||
is a dynamic window manager for X11. It manages windows in tiling and floating
|
is a dynamic window manager for X. It manages windows in tiling and floating
|
||||||
modes. Either mode can be applied dynamically, optimizing the environment for
|
modes. Either mode can be applied dynamically, optimizing the environment for
|
||||||
the application in use and the task performed.
|
the application in use and the task performed.
|
||||||
.P
|
.P
|
||||||
@ -21,47 +21,90 @@ tags. Selecting a certain tag for viewing will display all windows with that
|
|||||||
tag.
|
tag.
|
||||||
.P
|
.P
|
||||||
.B dwm
|
.B dwm
|
||||||
has a small status bar which displays the text read from standard
|
contains a small status bar which displays all available tags, the mode, the
|
||||||
input, if written. Besides that, it displays all available tags, and the title
|
title of the focused window, and the text read from standard input. The tags of
|
||||||
of the focused window. It draws a 1-pixel border around windows to
|
the focused window are highlighted with a small point.
|
||||||
indicate the focus state. Unfocused windows contain a small bar in front of
|
.P
|
||||||
them displaying their tags and title.
|
.B 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
|
||||||
prints version information to standard output, then exits.
|
prints version information to standard output, then exits.
|
||||||
.SH USAGE
|
.SH USAGE
|
||||||
|
.SS Status bar
|
||||||
|
.TP
|
||||||
|
.B Standard input
|
||||||
|
is read and displayed in the status text area.
|
||||||
|
.TP
|
||||||
|
.B Button1
|
||||||
|
click on a tag label views all windows with that
|
||||||
|
.BR tag ,
|
||||||
|
click on the mode label toggles between
|
||||||
|
.B tiled
|
||||||
|
and
|
||||||
|
.B floating
|
||||||
|
mode.
|
||||||
|
.TP
|
||||||
|
.B Button3
|
||||||
|
click on a tag label adds/removes all windows with that
|
||||||
|
.B tag
|
||||||
|
to/from the view.
|
||||||
|
.TP
|
||||||
|
.B Mod1-Button1
|
||||||
|
click on a tag label applies that
|
||||||
|
.B tag
|
||||||
|
to the focused
|
||||||
|
.BR window .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Button3
|
||||||
|
click on a tag label adds/removes that
|
||||||
|
.B tag
|
||||||
|
to/from the focused
|
||||||
|
.BR window .
|
||||||
|
.SS Keyboard commands
|
||||||
|
.TP
|
||||||
|
.B Mod1-Shift-Return
|
||||||
|
Start
|
||||||
|
.BR xterm (1).
|
||||||
|
.TP
|
||||||
|
.B Mod1-Tab
|
||||||
|
Focus next
|
||||||
|
.BR window .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Shift-Tab
|
||||||
|
Focus previous
|
||||||
|
.BR window .
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Return
|
.B Mod1-Return
|
||||||
Zoom
|
Zoom current
|
||||||
.B window
|
.B window
|
||||||
to the
|
to the
|
||||||
.B master
|
.B master
|
||||||
column
|
column
|
||||||
.TP
|
.RB ( tiling
|
||||||
.B Mod1-h
|
mode only).
|
||||||
Focus previous
|
|
||||||
.B tag
|
|
||||||
.TP
|
|
||||||
.B Mod1-j
|
|
||||||
Focus next
|
|
||||||
.B window
|
|
||||||
.TP
|
|
||||||
.B Mod1-k
|
|
||||||
Focus previous
|
|
||||||
.B window
|
|
||||||
.TP
|
|
||||||
.B Mod1-l
|
|
||||||
Focus next
|
|
||||||
.B tag
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-m
|
.B Mod1-m
|
||||||
Maximize current
|
Maximize current
|
||||||
.B window
|
.BR window .
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-[0..n]
|
.B Mod1-Shift-[1..n]
|
||||||
Focus
|
Apply
|
||||||
.B nth tag
|
.B nth tag
|
||||||
|
to current
|
||||||
|
.BR window .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Control-Shift-[1..n]
|
||||||
|
Add/remove
|
||||||
|
.B nth tag
|
||||||
|
to/from current
|
||||||
|
.BR window .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Shift-c
|
||||||
|
Close focused
|
||||||
|
.B window.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-space
|
.B Mod1-space
|
||||||
Toggle between
|
Toggle between
|
||||||
@ -69,44 +112,60 @@ Toggle between
|
|||||||
and
|
and
|
||||||
.B floating
|
.B floating
|
||||||
mode (affects
|
mode (affects
|
||||||
.BR "all windows" )
|
.BR "all windows" ).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-[0..n]
|
.B Mod1-[1..n]
|
||||||
Apply
|
View all windows with
|
||||||
.B nth tag
|
.BR "tag n" .
|
||||||
to current
|
.TP
|
||||||
.B window
|
.B Mod1-0
|
||||||
|
View all windows with any
|
||||||
|
.BR "tag" .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Control-[1..n]
|
||||||
|
Add/remove all windows with
|
||||||
|
.B tag n
|
||||||
|
to/from the view.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-q
|
.B Mod1-Shift-q
|
||||||
Quit
|
Quit
|
||||||
.B dwm
|
.B dwm.
|
||||||
.TP
|
.SS Mouse commands
|
||||||
.B Mod1-Shift-Return
|
|
||||||
Start
|
|
||||||
.B terminal
|
|
||||||
.TP
|
|
||||||
.B Mod1-Control-[0..n]
|
|
||||||
Append
|
|
||||||
.B nth tag
|
|
||||||
to current
|
|
||||||
.B window
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
Moves current
|
Move current
|
||||||
.B window
|
.B window
|
||||||
while dragging
|
while dragging
|
||||||
|
.RB ( floating
|
||||||
|
mode only).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button2
|
.B Mod1-Button2
|
||||||
Lowers current
|
Zoom current
|
||||||
.B window
|
.B window
|
||||||
|
to the
|
||||||
|
.B master
|
||||||
|
column
|
||||||
|
.RB ( tiling
|
||||||
|
mode only).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button3
|
.B Mod1-Button3
|
||||||
Resizes current
|
Resize current
|
||||||
.B window
|
.B window
|
||||||
while dragging
|
while dragging
|
||||||
|
.RB ( floating
|
||||||
|
mode only).
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
.B dwm
|
.B dwm
|
||||||
is customized by creating a custom config.h and (re)compiling the source
|
is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
|
.SH CAVEATS
|
||||||
|
The status bar may display
|
||||||
|
.B broken pipe
|
||||||
|
when
|
||||||
|
.B dwm
|
||||||
|
has been started by
|
||||||
|
.BR xdm (1),
|
||||||
|
because it closes standard output before executing
|
||||||
|
.BR dwm .
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1)
|
.BR dmenu (1)
|
||||||
|
71
dwm.h
71
dwm.h
@ -11,15 +11,10 @@
|
|||||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||||
#define PROTODELWIN 1
|
#define PROTODELWIN 1
|
||||||
|
|
||||||
typedef union Arg Arg;
|
typedef union {
|
||||||
typedef struct Client Client;
|
|
||||||
typedef struct DC DC;
|
|
||||||
typedef struct Fnt Fnt;
|
|
||||||
|
|
||||||
union Arg {
|
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
int i;
|
int i;
|
||||||
};
|
} Arg;
|
||||||
|
|
||||||
/* atoms */
|
/* atoms */
|
||||||
enum { NetSupported, NetWMName, NetLast };
|
enum { NetSupported, NetWMName, NetLast };
|
||||||
@ -28,27 +23,31 @@ enum { WMProtocols, WMDelete, WMLast };
|
|||||||
/* cursor */
|
/* cursor */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||||
|
|
||||||
/* windowcorners */
|
/* color */
|
||||||
|
enum { ColFG, ColBG, ColLast };
|
||||||
|
|
||||||
|
/* window corners */
|
||||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
||||||
|
|
||||||
struct Fnt {
|
typedef struct {
|
||||||
int ascent;
|
int ascent;
|
||||||
int descent;
|
int descent;
|
||||||
int height;
|
int height;
|
||||||
XFontSet set;
|
XFontSet set;
|
||||||
XFontStruct *xfont;
|
XFontStruct *xfont;
|
||||||
};
|
} Fnt;
|
||||||
|
|
||||||
struct DC { /* draw context */
|
typedef struct { /* draw context */
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned long bg;
|
unsigned long norm[ColLast];
|
||||||
unsigned long fg;
|
unsigned long sel[ColLast];
|
||||||
unsigned long border;
|
unsigned long status[ColLast];
|
||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
Fnt font;
|
Fnt font;
|
||||||
GC gc;
|
GC gc;
|
||||||
};
|
} DC;
|
||||||
|
|
||||||
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
char name[256];
|
char name[256];
|
||||||
int proto;
|
int proto;
|
||||||
@ -57,24 +56,23 @@ struct Client {
|
|||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
int grav;
|
int grav;
|
||||||
long flags;
|
long flags;
|
||||||
unsigned int border;
|
unsigned int border, weight;
|
||||||
Bool isfloat;
|
Bool isfloat;
|
||||||
Bool ismax;
|
|
||||||
Bool *tags;
|
Bool *tags;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *prev;
|
Client *prev;
|
||||||
Window win;
|
Window win;
|
||||||
Window title;
|
Window twin;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char *tags[];
|
extern const char *tags[];
|
||||||
extern char stext[1024];
|
extern char stext[1024];
|
||||||
extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
extern int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
||||||
extern unsigned int ntags;
|
extern unsigned int ntags, numlockmask;
|
||||||
extern void (*handler[LASTEvent])(XEvent *);
|
extern void (*handler[LASTEvent])(XEvent *);
|
||||||
extern void (*arrange)(Arg *);
|
extern void (*arrange)(Arg *);
|
||||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||||
extern Bool running, issel;
|
extern Bool running, issel, maximized, *seltag;
|
||||||
extern Client *clients, *sel;
|
extern Client *clients, *sel;
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc;
|
extern DC dc;
|
||||||
@ -84,21 +82,16 @@ extern Window root, barwin;
|
|||||||
/* client.c */
|
/* client.c */
|
||||||
extern void ban(Client *c);
|
extern void ban(Client *c);
|
||||||
extern void focus(Client *c);
|
extern void focus(Client *c);
|
||||||
extern void focusnext(Arg *arg);
|
|
||||||
extern void focusprev(Arg *arg);
|
|
||||||
extern Client *getclient(Window w);
|
extern Client *getclient(Window w);
|
||||||
extern Client *getctitle(Window w);
|
extern Client *getctitle(Window w);
|
||||||
extern void gravitate(Client *c, Bool invert);
|
extern void gravitate(Client *c, Bool invert);
|
||||||
extern void higher(Client *c);
|
|
||||||
extern void killclient(Arg *arg);
|
extern void killclient(Arg *arg);
|
||||||
extern void lower(Client *c);
|
|
||||||
extern void manage(Window w, XWindowAttributes *wa);
|
extern void manage(Window w, XWindowAttributes *wa);
|
||||||
extern void resize(Client *c, Bool sizehints, Corner sticky);
|
extern void resize(Client *c, Bool sizehints, Corner sticky);
|
||||||
extern void setsize(Client *c);
|
extern void setsize(Client *c);
|
||||||
extern void settitle(Client *c);
|
extern void settitle(Client *c);
|
||||||
extern void togglemax(Arg *arg);
|
extern void togglemax(Arg *arg);
|
||||||
extern void unmanage(Client *c);
|
extern void unmanage(Client *c);
|
||||||
extern void zoom(Arg *arg);
|
|
||||||
|
|
||||||
/* draw.c */
|
/* draw.c */
|
||||||
extern void drawall();
|
extern void drawall();
|
||||||
@ -110,6 +103,7 @@ extern unsigned int textw(const char *text);
|
|||||||
|
|
||||||
/* event.c */
|
/* event.c */
|
||||||
extern void grabkeys();
|
extern void grabkeys();
|
||||||
|
extern void procevent();
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
extern int getproto(Window w);
|
extern int getproto(Window w);
|
||||||
@ -118,20 +112,29 @@ extern void sendevent(Window w, Atom a, long value);
|
|||||||
extern int xerror(Display *dsply, XErrorEvent *ee);
|
extern int xerror(Display *dsply, XErrorEvent *ee);
|
||||||
|
|
||||||
/* tag.c */
|
/* tag.c */
|
||||||
extern void appendtag(Arg *arg);
|
|
||||||
extern void dofloat(Arg *arg);
|
|
||||||
extern void dotile(Arg *arg);
|
|
||||||
extern void initrregs();
|
extern void initrregs();
|
||||||
extern Client *getnext(Client *c);
|
extern Client *getnext(Client *c);
|
||||||
extern Client *getprev(Client *c);
|
extern Client *getprev(Client *c);
|
||||||
extern void replacetag(Arg *arg);
|
|
||||||
extern void settags(Client *c);
|
extern void settags(Client *c);
|
||||||
extern void togglemode(Arg *arg);
|
extern void tag(Arg *arg);
|
||||||
extern void view(Arg *arg);
|
extern void toggletag(Arg *arg);
|
||||||
extern void viewnext(Arg *arg);
|
|
||||||
extern void viewprev(Arg *arg);
|
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
extern void *emallocz(unsigned int size);
|
extern void *emallocz(unsigned int size);
|
||||||
extern void eprint(const char *errstr, ...);
|
extern void eprint(const char *errstr, ...);
|
||||||
|
extern void *erealloc(void *ptr, unsigned int size);
|
||||||
extern void spawn(Arg *arg);
|
extern void spawn(Arg *arg);
|
||||||
|
|
||||||
|
/* view.c */
|
||||||
|
extern void detach(Client *c);
|
||||||
|
extern void dofloat(Arg *arg);
|
||||||
|
extern void dotile(Arg *arg);
|
||||||
|
extern void focusnext(Arg *arg);
|
||||||
|
extern void focusprev(Arg *arg);
|
||||||
|
extern Bool isvisible(Client *c);
|
||||||
|
extern void restack();
|
||||||
|
extern void togglemode(Arg *arg);
|
||||||
|
extern void toggleview(Arg *arg);
|
||||||
|
extern void view(Arg *arg);
|
||||||
|
extern void viewall(Arg *arg);
|
||||||
|
extern void zoom(Arg *arg);
|
||||||
|
125
dwm.html
125
dwm.html
@ -1,125 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>dwm - dynamic window manager</title>
|
|
||||||
<meta name="author" content="Anselm R. Garbe">
|
|
||||||
<meta name="generator" content="ed">
|
|
||||||
<meta name="copyright" content="(C)opyright 2006 by Anselm R. Garbe">
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
color: #000000;
|
|
||||||
font-family: sans-serif;
|
|
||||||
margin: 20px 20px 20px 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<center>
|
|
||||||
<img src="dwm.png"/><br />
|
|
||||||
<h3>dynamic window manager</h3>
|
|
||||||
</center>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
dwm is a dynamic window manager for X11.
|
|
||||||
</p>
|
|
||||||
<h4>Philosophy</h4>
|
|
||||||
<p>
|
|
||||||
As founder and main developer of wmii I came to the conclusion that
|
|
||||||
wmii is too clunky for my needs. I don't need so many funky features
|
|
||||||
and all this hype about remote control through a 9P service, I only
|
|
||||||
want to manage my windows in a simple, but dynamic way. wmii never got
|
|
||||||
finished because I listened to users, who proposed arbitrary ideas I
|
|
||||||
considered useful. This resulted in an extreme <a
|
|
||||||
href="http://www.jwz.org/doc/cadt.html">CADT</a> development model,
|
|
||||||
which was a mistake. Thus the philosophy of dwm is simply <i>to fit my
|
|
||||||
needs</i> (maybe yours as well). That's it.
|
|
||||||
</p>
|
|
||||||
<h4>Differences to ion, larswm, and wmii</h4>
|
|
||||||
<p>
|
|
||||||
In contrast to ion, larswm, and wmii, dwm is much smaller, faster and simpler.
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
dwm has no Lua integration, no 9P support, no editable
|
|
||||||
tagbars, no shell-based configuration, no remote control, and comes
|
|
||||||
without any additional tools like printing the selection or warping
|
|
||||||
the mouse.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm is only a single binary, it's source code is intended to never
|
|
||||||
exceed 2000 SLOC.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm is based on tagging and dynamic window management (however
|
|
||||||
simpler than ion, wmii or larswm). It manages windows in
|
|
||||||
tiling and floating modes. Either mode can be applied dynamically,
|
|
||||||
depending on the application in use and the task performed.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm don't distinguishes between layers, there is no floating or
|
|
||||||
tiled layer. Wether the clients of currently selected tag are in
|
|
||||||
tiled mode or not, you can re-arrange all clients on the fly.
|
|
||||||
Popup- and fixed-size windows are treated floating, however.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm is customized through editing its source code, that makes it
|
|
||||||
extremely fast and secure - it does not process any input data
|
|
||||||
which hasn't been known at compile time, except window title names
|
|
||||||
and status text read from standard input. You don't have to learn
|
|
||||||
Lua/sh/ruby or some weird configuration file format (like X
|
|
||||||
resource files), beside C to customize it for your needs,
|
|
||||||
you <b>only</b> have to learn C (at least editing header files).
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Because dwm is customized through editing its source code, it's
|
|
||||||
pointless to make binary packages of it. This keeps its userbase
|
|
||||||
small and elitist. No novices asking stupid questions.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm uses 1-pixel borders to provide the maximum of screen real
|
|
||||||
estate to clients. Small titlebars are only drawn in front of
|
|
||||||
unfocused clients.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
dwm reads from standard input to print arbitrary status text (like
|
|
||||||
the date, load, battery charge). That's much simpler than
|
|
||||||
larsremote, wmiir and what not...
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
It can be downloaded and distributed under the conditions
|
|
||||||
of the <a href="http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm?f=f10eb1139362;file=LICENSE;style=raw">MIT/X Consortium license</a>.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Optionally you can install <b>dmenu</b> to extend dwm with a wmii-alike menu.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<h4>Links</h4>
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://10kloc.org/cgi-bin/man/man2html?query=dwm">Man page</a></li>
|
|
||||||
<li><a href="http://10kloc.org/shots/dwm-20060801.png">Screenshot</a> (20060801)</li>
|
|
||||||
<li><a href="http://10kloc.org/download/poster.ps">A4 poster (PostScript)</a></li>
|
|
||||||
<li>Mailing List: <a href="http://10kloc.org/cgi-bin/mailman/listinfo/dwm">dwm at wmii dot de</a> <a href="http://10kloc.org/pipermail/dwm/">(Archives)</a></li>
|
|
||||||
<li>IRC channel: <code>#dwm</code> at <code>irc.oftc.net</code></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Download</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://10kloc.org/download/dwm-0.7.tar.gz">dwm 0.7</a> (14kb) (20060807)</li>
|
|
||||||
<li><a href="http://10kloc.org/download/dmenu-0.2.tar.gz">dmenu 0.2</a> (7kb) (20060807)</li>
|
|
||||||
</ul>
|
|
||||||
<h3>Development</h3>
|
|
||||||
<p>
|
|
||||||
dwm is actively developed in parallel to wmii. You can <a href="http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm">browse</a> its source code repository or get a copy using <a href="http://www.selenic.com/mercurial/">Mercurial</a> with following command:
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<code>hg clone http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm</code>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<code>hg clone http://10kloc.org/cgi-bin/hgwebdir.cgi/dmenu</code>
|
|
||||||
</p>
|
|
||||||
<h3>Miscellaneous</h3>
|
|
||||||
<p>
|
|
||||||
You can purchase this <a href="https://www.spreadshirt.net/shop.php?op=article&article_id=3298632&view=403">tricot</a>
|
|
||||||
if you like dwm and the dwm logo, which has been designed by Anselm.
|
|
||||||
</p>
|
|
||||||
<p><small>--Anselm</small></p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
171
event.c
171
event.c
@ -18,7 +18,7 @@ typedef struct {
|
|||||||
|
|
||||||
KEYS
|
KEYS
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
movemouse(Client *c)
|
movemouse(Client *c)
|
||||||
@ -58,6 +58,7 @@ static void
|
|||||||
resizemouse(Client *c)
|
resizemouse(Client *c)
|
||||||
{
|
{
|
||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
|
int nw, nh;
|
||||||
Corner sticky;
|
Corner sticky;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
@ -76,8 +77,10 @@ resizemouse(Client *c)
|
|||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
c->w = abs(ocx - ev.xmotion.x);
|
if((nw = abs(ocx - ev.xmotion.x)))
|
||||||
c->h = abs(ocy - ev.xmotion.y);
|
c->w = abs(ocx - ev.xmotion.x);
|
||||||
|
if((nh = abs(ocy - ev.xmotion.y)))
|
||||||
|
c->h = abs(ocy - ev.xmotion.y);
|
||||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||||
if(ocx <= ev.xmotion.x)
|
if(ocx <= ev.xmotion.x)
|
||||||
@ -102,59 +105,79 @@ buttonpress(XEvent *e)
|
|||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
|
||||||
if(barwin == ev->window) {
|
if(barwin == ev->window) {
|
||||||
switch(ev->button) {
|
x = 0;
|
||||||
default:
|
for(a.i = 0; a.i < ntags; a.i++) {
|
||||||
x = 0;
|
x += textw(tags[a.i]);
|
||||||
for(a.i = 0; a.i < ntags; a.i++) {
|
if(ev->x < x) {
|
||||||
x += textw(tags[a.i]);
|
if(ev->button == Button1) {
|
||||||
if(ev->x < x) {
|
if(ev->state & MODKEY)
|
||||||
view(&a);
|
tag(&a);
|
||||||
break;
|
else
|
||||||
|
view(&a);
|
||||||
}
|
}
|
||||||
|
else if(ev->button == Button3) {
|
||||||
|
if(ev->state & MODKEY)
|
||||||
|
toggletag(&a);
|
||||||
|
else
|
||||||
|
toggleview(&a);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case Button4:
|
if(ev->x < x + bmw) {
|
||||||
viewnext(&a);
|
if(ev->button == Button1)
|
||||||
break;
|
togglemode(NULL);
|
||||||
case Button5:
|
|
||||||
viewprev(&a);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if((c = getclient(ev->window))) {
|
else if((c = getclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
switch(ev->button) {
|
if(maximized || CLEANMASK(ev->state) != MODKEY)
|
||||||
default:
|
return;
|
||||||
break;
|
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||||
case Button1:
|
restack(c);
|
||||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
movemouse(c);
|
||||||
higher(c);
|
}
|
||||||
movemouse(c);
|
else if(ev->button == Button2)
|
||||||
}
|
zoom(NULL);
|
||||||
break;
|
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
||||||
case Button2:
|
restack(c);
|
||||||
lower(c);
|
resizemouse(c);
|
||||||
break;
|
|
||||||
case Button3:
|
|
||||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
|
||||||
higher(c);
|
|
||||||
resizemouse(c);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
synconfig(Client *c, int x, int y, int w, int h, unsigned int border)
|
||||||
|
{
|
||||||
|
XEvent synev;
|
||||||
|
|
||||||
|
synev.type = ConfigureNotify;
|
||||||
|
synev.xconfigure.display = dpy;
|
||||||
|
synev.xconfigure.event = c->win;
|
||||||
|
synev.xconfigure.window = c->win;
|
||||||
|
synev.xconfigure.x = x;
|
||||||
|
synev.xconfigure.y = y;
|
||||||
|
synev.xconfigure.width = w;
|
||||||
|
synev.xconfigure.height = h;
|
||||||
|
synev.xconfigure.border_width = border;
|
||||||
|
synev.xconfigure.above = None;
|
||||||
|
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
configurerequest(XEvent *e)
|
configurerequest(XEvent *e)
|
||||||
{
|
{
|
||||||
|
unsigned long newmask;
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
XEvent synev;
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
unsigned long newmask;
|
|
||||||
|
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
|
if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) {
|
||||||
|
synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
|
||||||
|
XSync(dpy, False);
|
||||||
|
return;
|
||||||
|
}
|
||||||
gravitate(c, True);
|
gravitate(c, True);
|
||||||
if(ev->value_mask & CWX)
|
if(ev->value_mask & CWX)
|
||||||
c->x = ev->x;
|
c->x = ev->x;
|
||||||
@ -174,20 +197,8 @@ configurerequest(XEvent *e)
|
|||||||
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
|
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
|
||||||
if(newmask)
|
if(newmask)
|
||||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||||
else {
|
else
|
||||||
synev.type = ConfigureNotify;
|
synconfig(c, c->x, c->y, c->w, c->h, c->border);
|
||||||
synev.xconfigure.display = dpy;
|
|
||||||
synev.xconfigure.event = c->win;
|
|
||||||
synev.xconfigure.window = c->win;
|
|
||||||
synev.xconfigure.x = c->x;
|
|
||||||
synev.xconfigure.y = c->y;
|
|
||||||
synev.xconfigure.width = c->w;
|
|
||||||
synev.xconfigure.height = c->h;
|
|
||||||
synev.xconfigure.border_width = c->border;
|
|
||||||
synev.xconfigure.above = None;
|
|
||||||
/* Send synthetic ConfigureNotify */
|
|
||||||
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
|
||||||
}
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
if(c->isfloat)
|
if(c->isfloat)
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
@ -223,13 +234,16 @@ enternotify(XEvent *e)
|
|||||||
Client *c;
|
Client *c;
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
|
|
||||||
if(ev->detail == NotifyInferior)
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
|
if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
|
||||||
focus(c);
|
focus(c);
|
||||||
else if(ev->window == root)
|
else if(ev->window == root) {
|
||||||
issel = True;
|
issel = True;
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
|
drawall();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -255,13 +269,15 @@ keypress(XEvent *e)
|
|||||||
XKeyEvent *ev = &e->xkey;
|
XKeyEvent *ev = &e->xkey;
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++) {
|
||||||
if(keysym == key[i].keysym &&
|
if(keysym == key[i].keysym &&
|
||||||
CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
|
CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||||
|
{
|
||||||
if(key[i].func)
|
if(key[i].func)
|
||||||
key[i].func(&key[i].arg);
|
key[i].func(&key[i].arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -269,8 +285,20 @@ 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 = True;
|
issel = False;
|
||||||
|
drawall();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mappingnotify(XEvent *e)
|
||||||
|
{
|
||||||
|
XMappingEvent *ev = &e->xmapping;
|
||||||
|
|
||||||
|
XRefreshKeyboardMapping(ev);
|
||||||
|
if(ev->request == MappingKeyboard)
|
||||||
|
grabkeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -345,6 +373,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
|||||||
[LeaveNotify] = leavenotify,
|
[LeaveNotify] = leavenotify,
|
||||||
[Expose] = expose,
|
[Expose] = expose,
|
||||||
[KeyPress] = keypress,
|
[KeyPress] = keypress,
|
||||||
|
[MappingNotify] = mappingnotify,
|
||||||
[MapRequest] = maprequest,
|
[MapRequest] = maprequest,
|
||||||
[PropertyNotify] = propertynotify,
|
[PropertyNotify] = propertynotify,
|
||||||
[UnmapNotify] = unmapnotify
|
[UnmapNotify] = unmapnotify
|
||||||
@ -357,23 +386,29 @@ grabkeys()
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
|
|
||||||
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
code = XKeysymToKeycode(dpy, key[i].keysym);
|
code = XKeysymToKeycode(dpy, key[i].keysym);
|
||||||
/* normal */
|
|
||||||
XUngrabKey(dpy, code, key[i].mod, root);
|
|
||||||
XGrabKey(dpy, code, key[i].mod, root, True,
|
XGrabKey(dpy, code, key[i].mod, root, True,
|
||||||
GrabModeAsync, GrabModeAsync);
|
GrabModeAsync, GrabModeAsync);
|
||||||
/* capslock */
|
|
||||||
XUngrabKey(dpy, code, key[i].mod | LockMask, root);
|
|
||||||
XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
|
XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
|
||||||
GrabModeAsync, GrabModeAsync);
|
GrabModeAsync, GrabModeAsync);
|
||||||
/* numlock */
|
XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
|
||||||
XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root);
|
|
||||||
XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True,
|
|
||||||
GrabModeAsync, GrabModeAsync);
|
GrabModeAsync, GrabModeAsync);
|
||||||
/* capslock & numlock */
|
XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
|
||||||
XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root);
|
|
||||||
XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True,
|
|
||||||
GrabModeAsync, GrabModeAsync);
|
GrabModeAsync, GrabModeAsync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
procevent()
|
||||||
|
{
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
while(XPending(dpy)) {
|
||||||
|
XNextEvent(dpy, &ev);
|
||||||
|
if(handler[ev.type])
|
||||||
|
(handler[ev.type])(&ev); /* call handler */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
241
main.c
241
main.c
@ -11,22 +11,50 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
|
|
||||||
|
/* extern */
|
||||||
|
|
||||||
|
char stext[1024];
|
||||||
|
Bool *seltag;
|
||||||
|
int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
||||||
|
unsigned int ntags, numlockmask;
|
||||||
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
|
Bool running = True;
|
||||||
|
Bool issel = True;
|
||||||
|
Bool maximized = False;
|
||||||
|
Client *clients = NULL;
|
||||||
|
Client *sel = NULL;
|
||||||
|
Cursor cursor[CurLast];
|
||||||
|
Display *dpy;
|
||||||
|
DC dc = {0};
|
||||||
|
Window root, barwin;
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
static Bool otherwm;
|
static Bool otherwm, readin;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
|
close(STDIN_FILENO);
|
||||||
while(sel) {
|
while(sel) {
|
||||||
resize(sel, True, TopLeft);
|
resize(sel, True, TopLeft);
|
||||||
unmanage(sel);
|
unmanage(sel);
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||||
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -36,6 +64,7 @@ scan()
|
|||||||
Window *wins, d1, d2;
|
Window *wins, d1, d2;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
|
|
||||||
|
wins = NULL;
|
||||||
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||||
for(i = 0; i < num; i++) {
|
for(i = 0; i < num; i++) {
|
||||||
if(!XGetWindowAttributes(dpy, wins[i], &wa))
|
if(!XGetWindowAttributes(dpy, wins[i], &wa))
|
||||||
@ -50,23 +79,81 @@ scan()
|
|||||||
XFree(wins);
|
XFree(wins);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
setup()
|
||||||
{
|
{
|
||||||
int status, format;
|
int i, j;
|
||||||
unsigned long res, extra;
|
unsigned int mask;
|
||||||
Atom real;
|
Window w;
|
||||||
|
XModifierKeymap *modmap;
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
|
||||||
status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
|
/* init atoms */
|
||||||
&res, &extra, prop);
|
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||||
|
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||||
|
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||||
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||||
|
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||||
|
|
||||||
if(status != Success || *prop == 0) {
|
/* init cursors */
|
||||||
return 0;
|
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||||
|
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||||
|
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||||
|
|
||||||
|
modmap = XGetModifierMapping(dpy);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||||
|
if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||||
|
numlockmask = (1 << i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(res == 0) {
|
XFree(modmap);
|
||||||
free((void *) *prop);
|
|
||||||
}
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask;
|
||||||
return res;
|
wa.cursor = cursor[CurNormal];
|
||||||
|
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||||
|
|
||||||
|
grabkeys();
|
||||||
|
initrregs();
|
||||||
|
|
||||||
|
for(ntags = 0; tags[ntags]; ntags++);
|
||||||
|
seltag = emallocz(sizeof(Bool) * ntags);
|
||||||
|
seltag[0] = True;
|
||||||
|
|
||||||
|
/* style */
|
||||||
|
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||||
|
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||||
|
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||||
|
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||||
|
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||||
|
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||||
|
setfont(FONT);
|
||||||
|
|
||||||
|
bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);
|
||||||
|
sx = sy = 0;
|
||||||
|
sw = DisplayWidth(dpy, screen);
|
||||||
|
sh = DisplayHeight(dpy, screen);
|
||||||
|
mw = (sw * MASTERW) / 100;
|
||||||
|
|
||||||
|
bx = by = 0;
|
||||||
|
bw = sw;
|
||||||
|
dc.h = bh = dc.font.height + 2;
|
||||||
|
wa.override_redirect = 1;
|
||||||
|
wa.background_pixmap = ParentRelative;
|
||||||
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
|
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
|
||||||
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||||
|
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||||
|
XMapRaised(dpy, barwin);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
|
strcpy(stext, "dwm-"VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -82,38 +169,22 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
|
|||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
char stext[1024];
|
|
||||||
int tsel = DEFTAG;
|
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
|
||||||
unsigned int ntags;
|
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
|
||||||
Bool running = True;
|
|
||||||
Bool issel = True;
|
|
||||||
Client *clients = NULL;
|
|
||||||
Client *sel = NULL;
|
|
||||||
Cursor cursor[CurLast];
|
|
||||||
Display *dpy;
|
|
||||||
DC dc = {0};
|
|
||||||
Window root, barwin;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
getproto(Window w)
|
getproto(Window w)
|
||||||
{
|
{
|
||||||
int protos = 0;
|
int i, format, protos, status;
|
||||||
int i;
|
unsigned long extra, res;
|
||||||
long res;
|
Atom *protocols, real;
|
||||||
Atom *protocols;
|
|
||||||
|
|
||||||
res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L,
|
protos = 0;
|
||||||
((unsigned char **)&protocols));
|
status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
|
||||||
if(res <= 0) {
|
XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
|
||||||
|
if(status != Success || protocols == 0)
|
||||||
return protos;
|
return protos;
|
||||||
}
|
for(i = 0; i < res; i++)
|
||||||
for(i = 0; i < res; i++) {
|
|
||||||
if(protocols[i] == wmatom[WMDelete])
|
if(protocols[i] == wmatom[WMDelete])
|
||||||
protos |= PROTODELWIN;
|
protos |= PROTODELWIN;
|
||||||
}
|
free(protocols);
|
||||||
free((char *) protocols);
|
|
||||||
return protos;
|
return protos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +206,7 @@ sendevent(Window w, Atom a, long value)
|
|||||||
void
|
void
|
||||||
quit(Arg *arg)
|
quit(Arg *arg)
|
||||||
{
|
{
|
||||||
running = False;
|
readin = running = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -162,13 +233,8 @@ xerror(Display *dpy, XErrorEvent *ee)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int r, xfd;
|
||||||
unsigned int mask;
|
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
Bool readin = True;
|
|
||||||
Window w;
|
|
||||||
XEvent ev;
|
|
||||||
XSetWindowAttributes wa;
|
|
||||||
|
|
||||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||||
@ -181,6 +247,7 @@ main(int argc, char *argv[])
|
|||||||
if(!dpy)
|
if(!dpy)
|
||||||
eprint("dwm: cannot open display\n");
|
eprint("dwm: cannot open display\n");
|
||||||
|
|
||||||
|
xfd = ConnectionNumber(dpy);
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
|
|
||||||
@ -193,84 +260,28 @@ main(int argc, char *argv[])
|
|||||||
if(otherwm)
|
if(otherwm)
|
||||||
eprint("dwm: another window manager is already running\n");
|
eprint("dwm: another window manager is already running\n");
|
||||||
|
|
||||||
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(NULL);
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
xerrorxlib = XSetErrorHandler(xerror);
|
||||||
|
XSync(dpy, False);
|
||||||
|
|
||||||
/* init atoms */
|
setup();
|
||||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
|
||||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
|
||||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
|
||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
|
||||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
|
||||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
|
||||||
|
|
||||||
/* init cursors */
|
|
||||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
|
||||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
|
||||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
|
||||||
|
|
||||||
grabkeys();
|
|
||||||
initrregs();
|
|
||||||
|
|
||||||
for(ntags = 0; tags[ntags]; ntags++);
|
|
||||||
|
|
||||||
/* style */
|
|
||||||
dc.bg = getcolor(BGCOLOR);
|
|
||||||
dc.fg = getcolor(FGCOLOR);
|
|
||||||
dc.border = getcolor(BORDERCOLOR);
|
|
||||||
setfont(FONT);
|
|
||||||
|
|
||||||
sx = sy = 0;
|
|
||||||
sw = DisplayWidth(dpy, screen);
|
|
||||||
sh = DisplayHeight(dpy, screen);
|
|
||||||
mw = (sw * MASTERW) / 100;
|
|
||||||
|
|
||||||
wa.override_redirect = 1;
|
|
||||||
wa.background_pixmap = ParentRelative;
|
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
|
||||||
|
|
||||||
bx = by = 0;
|
|
||||||
bw = sw;
|
|
||||||
dc.h = bh = dc.font.height + 4;
|
|
||||||
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
|
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
|
||||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
|
||||||
XMapRaised(dpy, barwin);
|
|
||||||
|
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
|
||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
|
||||||
drawstatus();
|
drawstatus();
|
||||||
|
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
|
|
||||||
wa.cursor = cursor[CurNormal];
|
|
||||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
|
||||||
|
|
||||||
strcpy(stext, "dwm-"VERSION);
|
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
/* main event loop, reads status text from stdin as well */
|
/* main event loop, also reads status text from stdin */
|
||||||
|
XSync(dpy, False);
|
||||||
|
procevent();
|
||||||
|
readin = True;
|
||||||
while(running) {
|
while(running) {
|
||||||
FD_ZERO(&rd);
|
FD_ZERO(&rd);
|
||||||
if(readin)
|
if(readin)
|
||||||
FD_SET(STDIN_FILENO, &rd);
|
FD_SET(STDIN_FILENO, &rd);
|
||||||
FD_SET(ConnectionNumber(dpy), &rd);
|
FD_SET(xfd, &rd);
|
||||||
|
r = select(xfd + 1, &rd, NULL, NULL, NULL);
|
||||||
i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
|
if((r == -1) && (errno == EINTR))
|
||||||
if(i == -1 && errno == EINTR)
|
|
||||||
continue;
|
continue;
|
||||||
if(i < 0)
|
if(r > 0) {
|
||||||
eprint("select failed\n");
|
|
||||||
else if(i > 0) {
|
|
||||||
if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
|
|
||||||
while(XPending(dpy)) {
|
|
||||||
XNextEvent(dpy, &ev);
|
|
||||||
if(handler[ev.type])
|
|
||||||
(handler[ev.type])(&ev); /* call handler */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
||||||
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
||||||
if(readin)
|
if(readin)
|
||||||
@ -280,8 +291,10 @@ main(int argc, char *argv[])
|
|||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(r < 0)
|
||||||
|
eprint("select failed\n");
|
||||||
|
procevent();
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|
||||||
|
165
tag.c
165
tag.c
@ -30,116 +30,19 @@ RULES
|
|||||||
static RReg *rreg = NULL;
|
static RReg *rreg = NULL;
|
||||||
static unsigned int len = 0;
|
static unsigned int len = 0;
|
||||||
|
|
||||||
void (*arrange)(Arg *) = DEFMODE;
|
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void
|
|
||||||
appendtag(Arg *arg)
|
|
||||||
{
|
|
||||||
if(!sel)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sel->tags[arg->i] = True;
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dofloat(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
|
||||||
c->ismax = False;
|
|
||||||
if(c->tags[tsel]) {
|
|
||||||
resize(c, True, TopLeft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ban(c);
|
|
||||||
}
|
|
||||||
if((sel = getnext(clients))) {
|
|
||||||
higher(sel);
|
|
||||||
focus(sel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
drawall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dotile(Arg *arg)
|
|
||||||
{
|
|
||||||
int n, i, w, h;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
w = sw - mw;
|
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
|
||||||
if(c->tags[tsel] && !c->isfloat)
|
|
||||||
n++;
|
|
||||||
|
|
||||||
if(n > 1)
|
|
||||||
h = (sh - bh) / (n - 1);
|
|
||||||
else
|
|
||||||
h = sh - bh;
|
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
|
||||||
c->ismax = False;
|
|
||||||
if(c->tags[tsel]) {
|
|
||||||
if(c->isfloat) {
|
|
||||||
higher(c);
|
|
||||||
resize(c, True, TopLeft);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(n == 1) {
|
|
||||||
c->x = sx;
|
|
||||||
c->y = sy + bh;
|
|
||||||
c->w = sw - 2;
|
|
||||||
c->h = sh - 2 - bh;
|
|
||||||
}
|
|
||||||
else if(i == 0) {
|
|
||||||
c->x = sx;
|
|
||||||
c->y = sy + bh;
|
|
||||||
c->w = mw - 2;
|
|
||||||
c->h = sh - 2 - bh;
|
|
||||||
}
|
|
||||||
else if(h > bh) {
|
|
||||||
c->x = sx + mw;
|
|
||||||
c->y = sy + (i - 1) * h + bh;
|
|
||||||
c->w = w - 2;
|
|
||||||
c->h = h - 2;
|
|
||||||
}
|
|
||||||
else { /* fallback if h < bh */
|
|
||||||
c->x = sx + mw;
|
|
||||||
c->y = sy + bh;
|
|
||||||
c->w = w - 2;
|
|
||||||
c->h = sh - 2 - bh;
|
|
||||||
}
|
|
||||||
resize(c, False, TopLeft);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ban(c);
|
|
||||||
}
|
|
||||||
if((sel = getnext(clients))) {
|
|
||||||
higher(sel);
|
|
||||||
focus(sel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
drawall();
|
|
||||||
}
|
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getnext(Client *c)
|
getnext(Client *c)
|
||||||
{
|
{
|
||||||
for(; c && !c->tags[tsel]; c = c->next);
|
for(; c && !isvisible(c); c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getprev(Client *c)
|
getprev(Client *c)
|
||||||
{
|
{
|
||||||
for(; c && !c->tags[tsel]; c = c->prev);
|
for(; c && !isvisible(c); c = c->prev);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,34 +75,21 @@ initrregs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
replacetag(Arg *arg)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if(!sel)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
sel->tags[i] = False;
|
|
||||||
appendtag(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
settags(Client *c)
|
settags(Client *c)
|
||||||
{
|
{
|
||||||
char classinst[256];
|
char prop[512];
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
Bool matched = False;
|
Bool matched = False;
|
||||||
XClassHint ch;
|
XClassHint ch;
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
if(XGetClassHint(dpy, c->win, &ch)) {
|
||||||
snprintf(classinst, sizeof(classinst), "%s:%s",
|
snprintf(prop, sizeof(prop), "%s:%s:%s",
|
||||||
ch.res_class ? ch.res_class : "",
|
ch.res_class ? ch.res_class : "",
|
||||||
ch.res_name ? ch.res_name : "");
|
ch.res_name ? ch.res_name : "", c->name);
|
||||||
for(i = 0; !matched && i < len; i++)
|
for(i = 0; !matched && i < len; i++)
|
||||||
if(rreg[i].clregex && !regexec(rreg[i].clregex, classinst, 1, &tmp, 0)) {
|
if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
|
||||||
c->isfloat = rule[i].isfloat;
|
c->isfloat = rule[i].isfloat;
|
||||||
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
||||||
if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
|
if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
|
||||||
@ -214,34 +104,37 @@ settags(Client *c)
|
|||||||
XFree(ch.res_name);
|
XFree(ch.res_name);
|
||||||
}
|
}
|
||||||
if(!matched)
|
if(!matched)
|
||||||
c->tags[tsel] = True;
|
for(i = 0; i < ntags; i++)
|
||||||
|
c->tags[i] = seltag[i];
|
||||||
|
for(i = 0; i < ntags && !c->tags[i]; i++);
|
||||||
|
c->weight = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglemode(Arg *arg)
|
tag(Arg *arg)
|
||||||
{
|
{
|
||||||
arrange = arrange == dofloat ? dotile : dofloat;
|
unsigned int i;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
sel->tags[i] = False;
|
||||||
|
sel->tags[arg->i] = True;
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view(Arg *arg)
|
toggletag(Arg *arg)
|
||||||
{
|
{
|
||||||
tsel = arg->i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sel->tags[arg->i] = !sel->tags[arg->i];
|
||||||
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||||
|
if(i == ntags)
|
||||||
|
sel->tags[arg->i] = True;
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
drawall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
viewnext(Arg *arg)
|
|
||||||
{
|
|
||||||
arg->i = (tsel < ntags-1) ? tsel+1 : 0;
|
|
||||||
view(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
viewprev(Arg *arg)
|
|
||||||
{
|
|
||||||
arg->i = (tsel > 0) ? tsel-1 : ntags-1;
|
|
||||||
view(arg);
|
|
||||||
}
|
}
|
||||||
|
24
util.c
24
util.c
@ -9,14 +9,6 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* static */
|
|
||||||
|
|
||||||
static void
|
|
||||||
bad_malloc(unsigned int size)
|
|
||||||
{
|
|
||||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -25,7 +17,7 @@ emallocz(unsigned int size)
|
|||||||
void *res = calloc(1, size);
|
void *res = calloc(1, size);
|
||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
bad_malloc(size);
|
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +32,15 @@ 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)
|
||||||
{
|
{
|
||||||
@ -50,13 +51,14 @@ spawn(Arg *arg)
|
|||||||
|
|
||||||
if(!arg->cmd)
|
if(!arg->cmd)
|
||||||
return;
|
return;
|
||||||
|
/* the double-fork construct avoids zombie processes */
|
||||||
if(fork() == 0) {
|
if(fork() == 0) {
|
||||||
if(fork() == 0) {
|
if(fork() == 0) {
|
||||||
if(dpy)
|
if(dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
setsid();
|
setsid();
|
||||||
execl(shell, shell, "-c", arg->cmd, NULL);
|
execl(shell, shell, "-c", arg->cmd, (char *)NULL);
|
||||||
fprintf(stderr, "dwm: execl '%s'", arg->cmd);
|
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
|
||||||
perror(" failed");
|
perror(" failed");
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
|
298
view.c
Normal file
298
view.c
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
/*
|
||||||
|
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
|
* See LICENSE file for license details.
|
||||||
|
*/
|
||||||
|
#include "dwm.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
|
||||||
|
static Client *
|
||||||
|
minclient()
|
||||||
|
{
|
||||||
|
Client *c, *min;
|
||||||
|
|
||||||
|
for(min = c = clients; c; c = c->next)
|
||||||
|
if(c->weight < min->weight)
|
||||||
|
min = c;
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
reorder()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* extern */
|
||||||
|
|
||||||
|
void (*arrange)(Arg *) = DEFMODE;
|
||||||
|
|
||||||
|
void
|
||||||
|
detach(Client *c)
|
||||||
|
{
|
||||||
|
if(c->prev)
|
||||||
|
c->prev->next = c->next;
|
||||||
|
if(c->next)
|
||||||
|
c->next->prev = c->prev;
|
||||||
|
if(c == clients)
|
||||||
|
clients = c->next;
|
||||||
|
c->next = c->prev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dofloat(Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
maximized = False;
|
||||||
|
|
||||||
|
for(c = clients; c; c = c->next) {
|
||||||
|
if(isvisible(c)) {
|
||||||
|
resize(c, True, TopLeft);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ban(c);
|
||||||
|
}
|
||||||
|
if(!sel || !isvisible(sel))
|
||||||
|
focus(getnext(clients));
|
||||||
|
restack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dotile(Arg *arg)
|
||||||
|
{
|
||||||
|
int h, i, n, w;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
maximized = False;
|
||||||
|
|
||||||
|
w = sw - mw;
|
||||||
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && !c->isfloat)
|
||||||
|
n++;
|
||||||
|
|
||||||
|
if(n > 1)
|
||||||
|
h = (sh - bh) / (n - 1);
|
||||||
|
else
|
||||||
|
h = sh - bh;
|
||||||
|
|
||||||
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
|
if(isvisible(c)) {
|
||||||
|
if(c->isfloat) {
|
||||||
|
resize(c, True, TopLeft);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(n == 1) {
|
||||||
|
c->x = sx;
|
||||||
|
c->y = sy + bh;
|
||||||
|
c->w = sw - 2;
|
||||||
|
c->h = sh - 2 - bh;
|
||||||
|
}
|
||||||
|
else if(i == 0) {
|
||||||
|
c->x = sx;
|
||||||
|
c->y = sy + bh;
|
||||||
|
c->w = mw - 2;
|
||||||
|
c->h = sh - 2 - bh;
|
||||||
|
}
|
||||||
|
else if(h > bh) {
|
||||||
|
c->x = sx + mw;
|
||||||
|
c->y = sy + (i - 1) * h + bh;
|
||||||
|
c->w = w - 2;
|
||||||
|
if(i + 1 == n)
|
||||||
|
c->h = sh - c->y - 2;
|
||||||
|
else
|
||||||
|
c->h = h - 2;
|
||||||
|
}
|
||||||
|
else { /* fallback if h < bh */
|
||||||
|
c->x = sx + mw;
|
||||||
|
c->y = sy + bh;
|
||||||
|
c->w = w - 2;
|
||||||
|
c->h = sh - 2 - bh;
|
||||||
|
}
|
||||||
|
resize(c, False, TopLeft);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ban(c);
|
||||||
|
}
|
||||||
|
if(!sel || !isvisible(sel))
|
||||||
|
focus(getnext(clients));
|
||||||
|
restack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusnext(Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!(c = getnext(sel->next)))
|
||||||
|
c = getnext(clients);
|
||||||
|
if(c) {
|
||||||
|
focus(c);
|
||||||
|
restack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusprev(Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!(c = getprev(sel->prev))) {
|
||||||
|
for(c = clients; c && c->next; c = c->next);
|
||||||
|
c = getprev(c);
|
||||||
|
}
|
||||||
|
if(c) {
|
||||||
|
focus(c);
|
||||||
|
restack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
isvisible(Client *c)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
if(c->tags[i] && seltag[i])
|
||||||
|
return True;
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
restack()
|
||||||
|
{
|
||||||
|
static unsigned int nwins = 0;
|
||||||
|
static Window *wins = NULL;
|
||||||
|
unsigned int f, fi, m, mi, n;
|
||||||
|
Client *c;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
for(f = 0, m = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c)) {
|
||||||
|
if(c->isfloat || arrange == dofloat)
|
||||||
|
f++;
|
||||||
|
else
|
||||||
|
m++;
|
||||||
|
}
|
||||||
|
if(!(n = 2 * (f + m))) {
|
||||||
|
drawstatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(nwins < n) {
|
||||||
|
nwins = n;
|
||||||
|
wins = erealloc(wins, nwins * sizeof(Window));
|
||||||
|
}
|
||||||
|
|
||||||
|
fi = 0;
|
||||||
|
mi = 2 * f;
|
||||||
|
if(sel->isfloat || arrange == dofloat) {
|
||||||
|
wins[fi++] = sel->twin;
|
||||||
|
wins[fi++] = sel->win;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wins[mi++] = sel->twin;
|
||||||
|
wins[mi++] = sel->win;
|
||||||
|
}
|
||||||
|
for(c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && c != sel) {
|
||||||
|
if(c->isfloat || arrange == dofloat) {
|
||||||
|
wins[fi++] = c->twin;
|
||||||
|
wins[fi++] = c->win;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wins[mi++] = c->twin;
|
||||||
|
wins[mi++] = c->win;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XRestackWindows(dpy, wins, n);
|
||||||
|
drawall();
|
||||||
|
XSync(dpy, False);
|
||||||
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglemode(Arg *arg)
|
||||||
|
{
|
||||||
|
arrange = (arrange == dofloat) ? dotile : dofloat;
|
||||||
|
if(sel)
|
||||||
|
arrange(NULL);
|
||||||
|
else
|
||||||
|
drawstatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
toggleview(Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
seltag[arg->i] = !seltag[arg->i];
|
||||||
|
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||||
|
if(i == ntags)
|
||||||
|
seltag[arg->i] = True; /* cannot toggle last view */
|
||||||
|
reorder();
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
view(Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
seltag[i] = False;
|
||||||
|
seltag[arg->i] = True;
|
||||||
|
reorder();
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
viewall(Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
seltag[i] = True;
|
||||||
|
reorder();
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
zoom(Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c = sel;
|
||||||
|
|
||||||
|
if(!c || (arrange != dotile) || c->isfloat || maximized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(c == getnext(clients))
|
||||||
|
if(!(c = getnext(c->next)))
|
||||||
|
return;
|
||||||
|
detach(c);
|
||||||
|
c->next = clients;
|
||||||
|
clients->prev = c;
|
||||||
|
clients = c;
|
||||||
|
focus(c);
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
Reference in New Issue
Block a user