Compare commits
142 Commits
Author | SHA1 | Date | |
---|---|---|---|
57c49fe867 | |||
c60de1acd4 | |||
69b738c097 | |||
da0b2a2f31 | |||
2378a558a2 | |||
f18ed615ae | |||
f6656fffb4 | |||
aaad7bfd15 | |||
0915da8842 | |||
0d0e8bde13 | |||
838a1ff950 | |||
e1315fd40c | |||
52a3ab1042 | |||
a82e7b765e | |||
0ed0fa4d5b | |||
ec85fddb9a | |||
3a1343a245 | |||
9066ee2eb4 | |||
40bd21ce63 | |||
4633fbec61 | |||
25060031a5 | |||
c7ae6334b7 | |||
eac04882b4 | |||
6499fc4f93 | |||
04f27a5438 | |||
1b3903d6e9 | |||
cc05093b0d | |||
6436dd4438 | |||
26c50c780e | |||
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 |
5
.hgtags
5
.hgtags
@ -6,3 +6,8 @@ eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
|||||||
c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
||||||
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
||||||
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
||||||
|
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
||||||
|
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||||
|
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||||
|
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||||
|
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
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
|
||||||
|
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
|
||||||
|
235
client.c
235
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(isvisible(c))
|
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,57 +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;
|
||||||
|
|
||||||
if (!issel)
|
if(!issel)
|
||||||
return;
|
return;
|
||||||
if(sel && sel->ismax)
|
|
||||||
togglemax(NULL);
|
|
||||||
sel = c;
|
|
||||||
if(old && old != c)
|
|
||||||
drawtitle(old);
|
|
||||||
drawtitle(c);
|
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
focusnext(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
sel = c;
|
||||||
|
else if(sel != c) {
|
||||||
if(!(c = getnext(sel->next)))
|
if(maximized)
|
||||||
c = getnext(clients);
|
togglemax(NULL);
|
||||||
if(c) {
|
old = sel;
|
||||||
focus(c);
|
sel = c;
|
||||||
restack();
|
if(old) {
|
||||||
}
|
grabbuttons(old, False);
|
||||||
}
|
drawtitle(old);
|
||||||
|
}
|
||||||
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) {
|
if(c) {
|
||||||
focus(c);
|
grabbuttons(c, True);
|
||||||
restack();
|
drawtitle(c);
|
||||||
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
@ -113,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;
|
||||||
}
|
}
|
||||||
@ -187,6 +198,7 @@ killclient(Arg *arg)
|
|||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
Client *c;
|
Client *c;
|
||||||
Window trans;
|
Window trans;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
@ -203,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,
|
||||||
@ -214,57 +232,30 @@ 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);
|
||||||
|
settags(c, getclient(trans));
|
||||||
|
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);
|
||||||
|
ban(c);
|
||||||
if(isvisible(c))
|
|
||||||
sel = c;
|
|
||||||
arrange(NULL);
|
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
XMapWindow(dpy, c->title);
|
XMapWindow(dpy, c->twin);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -272,7 +263,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) {
|
||||||
@ -289,10 +279,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)
|
||||||
@ -382,12 +368,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;
|
||||||
@ -398,6 +385,9 @@ togglemax(Arg *arg)
|
|||||||
sel->h = sh - 2 - bh;
|
sel->h = sh - 2 - bh;
|
||||||
|
|
||||||
restack();
|
restack();
|
||||||
|
for(c = getnext(clients); c; c = getnext(c->next))
|
||||||
|
if(c != sel)
|
||||||
|
ban(c);
|
||||||
resize(sel, arrange == dofloat, TopLeft);
|
resize(sel, arrange == dofloat, TopLeft);
|
||||||
|
|
||||||
sel->x = ox;
|
sel->x = ox;
|
||||||
@ -406,61 +396,36 @@ 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(sel == c) {
|
||||||
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
|
if(trans && (tc = getclient(trans)) && isvisible(tc))
|
||||||
|
fc = tc;
|
||||||
|
else
|
||||||
|
fc = getnext(clients);
|
||||||
|
focus(fc);
|
||||||
|
}
|
||||||
|
|
||||||
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
|
XDestroyWindow(dpy, c->twin);
|
||||||
|
|
||||||
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)
|
|
||||||
sel = getnext(clients);
|
|
||||||
free(c->tags);
|
free(c->tags);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
if(sel)
|
|
||||||
focus(sel);
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
zoom(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(sel == getnext(clients)) {
|
|
||||||
if((c = getnext(sel->next)))
|
|
||||||
sel = c;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pop */
|
|
||||||
sel->prev->next = sel->next;
|
|
||||||
if(sel->next)
|
|
||||||
sel->next->prev = sel->prev;
|
|
||||||
sel->prev = NULL;
|
|
||||||
clients->prev = sel;
|
|
||||||
sel->next = clients;
|
|
||||||
clients = sel;
|
|
||||||
focus(sel);
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
32
config.arg.h
32
config.arg.h
@ -4,14 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "work", "net", "fnord", NULL };
|
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define DEFTAG 0 /* index */
|
#define FLOATSYMBOL "><>"
|
||||||
|
#define TILESYMBOL "[]="
|
||||||
|
|
||||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
||||||
#define BGCOLOR "#0d121d"
|
#define SELBGCOLOR "#333366"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define BORDERCOLOR "#3f484d"
|
#define NORMBGCOLOR "#333333"
|
||||||
|
#define NORMFGCOLOR "#dddddd"
|
||||||
|
#define STATUSBGCOLOR "#222222"
|
||||||
|
#define STATUSFGCOLOR "#9999cc"
|
||||||
|
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
@ -19,34 +25,42 @@ const char *tags[] = { "work", "net", "fnord", NULL };
|
|||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function arguments */ \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||||
{ .cmd = "exec urxvt +sb -tr -bg black -fg '#eeeeee' -fn '"FONT"'" } }, \
|
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||||
{ MODKEY, XK_p, spawn, \
|
{ MODKEY, XK_p, spawn, \
|
||||||
{ .cmd = "exec `ls -lL /usr/bin /usr/local/bin 2>/dev/null | " \
|
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
||||||
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | dmenu`" } }, \
|
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
|
||||||
|
"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_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||||
|
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
|
||||||
|
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
|
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
|
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
{ 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,14 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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 MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
@ -23,34 +29,39 @@ static Key key[] = { \
|
|||||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = 0 } }, \
|
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 1 } }, \
|
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 3 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_4, tag, { .i = 4 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_0, toggletag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 2 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 3 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 4 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY, XK_0, view, { .i = 0 } }, \
|
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 1 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 2 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 3 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
{ MODKEY, XK_4, view, { .i = 4 } }, \
|
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||||
{ MODKEY|ControlMask, XK_0, toggleview, { .i = 0 } }, \
|
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 1 } }, \
|
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 2 } }, \
|
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 3 } }, \
|
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||||
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 4 } }, \
|
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
{ 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.9
|
VERSION = 1.4
|
||||||
|
|
||||||
# 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
|
||||||
|
95
draw.c
95
draw.c
@ -22,30 +22,16 @@ textnw(const char *text, unsigned int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, Bool invert)
|
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, olen;
|
unsigned int len, olen;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XPoint points[5];
|
|
||||||
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);
|
||||||
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);
|
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
@ -75,18 +61,21 @@ drawtext(const char *text, Bool invert)
|
|||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,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);
|
|
||||||
|
|
||||||
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], seltag[i]);
|
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||||
else
|
else
|
||||||
drawtext(tags[i], !seltag[i]);
|
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);
|
if(dc.x < x) {
|
||||||
if(sel && ((dc.w = dc.x - x) >= bh)) {
|
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
drawtext(sel->name, istile);
|
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);
|
||||||
@ -136,33 +133,19 @@ drawstatus()
|
|||||||
void
|
void
|
||||||
drawtitle(Client *c)
|
drawtitle(Client *c)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
Bool istile = arrange == dotile;
|
|
||||||
|
|
||||||
if(c == sel && issel) {
|
if(c == sel && issel) {
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = c->tw - dc.x;
|
|
||||||
drawtext(c->name, !istile);
|
|
||||||
XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
dwm.1
59
dwm.1
@ -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,11 +21,13 @@ 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
|
||||||
@ -38,12 +40,29 @@ is read and displayed in the status text area.
|
|||||||
.TP
|
.TP
|
||||||
.B Button1
|
.B Button1
|
||||||
click on a tag label views all windows with that
|
click on a tag label views all windows with that
|
||||||
.BR tag .
|
.BR tag ,
|
||||||
|
click on the mode label toggles between
|
||||||
|
.B tiled
|
||||||
|
and
|
||||||
|
.B floating
|
||||||
|
mode.
|
||||||
.TP
|
.TP
|
||||||
.B Button3
|
.B Button3
|
||||||
click on a tag label adds/removes all windows with that
|
click on a tag label adds/removes all windows with that
|
||||||
.B tag
|
.B tag
|
||||||
to/from the view.
|
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
|
.SS Keyboard commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-Return
|
.B Mod1-Shift-Return
|
||||||
@ -71,13 +90,25 @@ mode only).
|
|||||||
Maximize current
|
Maximize current
|
||||||
.BR window .
|
.BR window .
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-[0..n]
|
.B Mod1-g
|
||||||
|
Grow current
|
||||||
|
.BR column
|
||||||
|
.RB ( tiling
|
||||||
|
mode only).
|
||||||
|
.TP
|
||||||
|
.B Mod1-s
|
||||||
|
Shrink current
|
||||||
|
.BR column
|
||||||
|
.RB ( tiling
|
||||||
|
mode only).
|
||||||
|
.TP
|
||||||
|
.B Mod1-Shift-[1..n]
|
||||||
Apply
|
Apply
|
||||||
.B nth tag
|
.B nth tag
|
||||||
to current
|
to current
|
||||||
.BR window .
|
.BR window .
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Control-Shift-[0..n]
|
.B Mod1-Control-Shift-[1..n]
|
||||||
Add/remove
|
Add/remove
|
||||||
.B nth tag
|
.B nth tag
|
||||||
to/from current
|
to/from current
|
||||||
@ -95,11 +126,15 @@ and
|
|||||||
mode (affects
|
mode (affects
|
||||||
.BR "all windows" ).
|
.BR "all windows" ).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-[0..n]
|
.B Mod1-[1..n]
|
||||||
View all windows with
|
View all windows with
|
||||||
.BR "tag n" .
|
.BR "tag n" .
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Control-[0..n]
|
.B Mod1-0
|
||||||
|
View all windows with any
|
||||||
|
.BR "tag" .
|
||||||
|
.TP
|
||||||
|
.B Mod1-Control-[1..n]
|
||||||
Add/remove all windows with
|
Add/remove all windows with
|
||||||
.B tag n
|
.B tag n
|
||||||
to/from the view.
|
to/from the view.
|
||||||
@ -136,7 +171,7 @@ mode only).
|
|||||||
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
|
.SH CAVEATS
|
||||||
The status bar displays
|
The status bar may display
|
||||||
.B broken pipe
|
.B broken pipe
|
||||||
when
|
when
|
||||||
.B dwm
|
.B dwm
|
||||||
|
65
dwm.h
65
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 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, numlockmask;
|
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, *seltag;
|
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,8 +82,6 @@ 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);
|
||||||
@ -96,7 +92,6 @@ 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();
|
||||||
@ -117,22 +112,30 @@ 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 dofloat(Arg *arg);
|
|
||||||
extern void dotile(Arg *arg);
|
|
||||||
extern void initrregs();
|
extern void initrregs();
|
||||||
extern Bool isvisible(Client *c);
|
|
||||||
extern Client *getnext(Client *c);
|
extern Client *getnext(Client *c);
|
||||||
extern Client *getprev(Client *c);
|
extern Client *getprev(Client *c);
|
||||||
extern void restack();
|
extern void settags(Client *c, Client *trans);
|
||||||
extern void settags(Client *c);
|
|
||||||
extern void tag(Arg *arg);
|
extern void tag(Arg *arg);
|
||||||
extern void togglemode(Arg *arg);
|
|
||||||
extern void toggletag(Arg *arg);
|
extern void toggletag(Arg *arg);
|
||||||
extern void toggleview(Arg *arg);
|
|
||||||
extern void view(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 *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 resizecol(Arg *arg);
|
||||||
|
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);
|
||||||
|
127
dwm.html
127
dwm.html
@ -1,127 +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">
|
|
||||||
<link rel="dwm icon" href="favicon.ico" type="image/x-icon" />
|
|
||||||
<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>Background</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 doesn'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-20060810a.png">Screenshot of tiled mode</a> (20060810)</li>
|
|
||||||
<li><a href="http://10kloc.org/shots/dwm-20060810b.png">Screenshotof floating mode</a> (20060810)</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.9.tar.gz">dwm 0.9</a> (15kb) (20060815)</li>
|
|
||||||
<li><a href="http://10kloc.org/download/dmenu-0.4.tar.gz">dmenu 0.4</a> (7kb) (20060815)</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>
|
|
87
event.c
87
event.c
@ -109,48 +109,75 @@ buttonpress(XEvent *e)
|
|||||||
for(a.i = 0; a.i < ntags; a.i++) {
|
for(a.i = 0; a.i < ntags; a.i++) {
|
||||||
x += textw(tags[a.i]);
|
x += textw(tags[a.i]);
|
||||||
if(ev->x < x) {
|
if(ev->x < x) {
|
||||||
if(ev->button == Button1)
|
if(ev->button == Button1) {
|
||||||
view(&a);
|
if(ev->state & MODKEY)
|
||||||
else if(ev->button == Button3)
|
tag(&a);
|
||||||
toggleview(&a);
|
else
|
||||||
|
view(&a);
|
||||||
|
}
|
||||||
|
else if(ev->button == Button3) {
|
||||||
|
if(ev->state & MODKEY)
|
||||||
|
toggletag(&a);
|
||||||
|
else
|
||||||
|
toggleview(&a);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(ev->x < x + bmw) {
|
||||||
|
if(ev->button == Button1)
|
||||||
|
togglemode(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
restack(c);
|
}
|
||||||
movemouse(c);
|
else if(ev->button == Button2)
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Button2:
|
|
||||||
zoom(NULL);
|
zoom(NULL);
|
||||||
break;
|
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
||||||
case Button3:
|
restack(c);
|
||||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
resizemouse(c);
|
||||||
restack(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;
|
unsigned long newmask;
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
XEvent synev;
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
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;
|
||||||
@ -170,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);
|
||||||
|
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 198 B |
311
main.c
311
main.c
@ -15,14 +15,32 @@
|
|||||||
#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);
|
||||||
@ -32,11 +50,12 @@ cleanup()
|
|||||||
else
|
else
|
||||||
XFreeFont(dpy, dc.font.xfont);
|
XFreeFont(dpy, dc.font.xfont);
|
||||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
XDestroyWindow(dpy, barwin);
|
|
||||||
XFreePixmap(dpy, dc.drawable);
|
XFreePixmap(dpy, dc.drawable);
|
||||||
XFreeGC(dpy, dc.gc);
|
XFreeGC(dpy, dc.gc);
|
||||||
|
XDestroyWindow(dpy, barwin);
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
free(seltag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -61,155 +80,15 @@ 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;
|
|
||||||
Atom real;
|
|
||||||
|
|
||||||
status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
|
|
||||||
&res, &extra, prop);
|
|
||||||
|
|
||||||
if(status != Success || *prop == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(res == 0) {
|
|
||||||
free((void *) *prop);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Startup Error handler to check if another window manager
|
|
||||||
* is already running.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xerrorstart(Display *dsply, XErrorEvent *ee)
|
|
||||||
{
|
|
||||||
otherwm = True;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* extern */
|
|
||||||
|
|
||||||
char stext[1024];
|
|
||||||
Bool *seltag;
|
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
|
||||||
unsigned int ntags, numlockmask;
|
|
||||||
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
|
|
||||||
getproto(Window w)
|
|
||||||
{
|
|
||||||
int protos = 0;
|
|
||||||
int i;
|
|
||||||
long res;
|
|
||||||
Atom *protocols;
|
|
||||||
|
|
||||||
res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L,
|
|
||||||
((unsigned char **)&protocols));
|
|
||||||
if(res <= 0) {
|
|
||||||
return protos;
|
|
||||||
}
|
|
||||||
for(i = 0; i < res; i++) {
|
|
||||||
if(protocols[i] == wmatom[WMDelete])
|
|
||||||
protos |= PROTODELWIN;
|
|
||||||
}
|
|
||||||
free((char *) protocols);
|
|
||||||
return protos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sendevent(Window w, Atom a, long value)
|
|
||||||
{
|
|
||||||
XEvent e;
|
|
||||||
|
|
||||||
e.type = ClientMessage;
|
|
||||||
e.xclient.window = w;
|
|
||||||
e.xclient.message_type = a;
|
|
||||||
e.xclient.format = 32;
|
|
||||||
e.xclient.data.l[0] = value;
|
|
||||||
e.xclient.data.l[1] = CurrentTime;
|
|
||||||
XSendEvent(dpy, w, False, NoEventMask, &e);
|
|
||||||
XSync(dpy, False);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
quit(Arg *arg)
|
|
||||||
{
|
|
||||||
running = False;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There's no way to check accesses to destroyed windows, thus those cases are
|
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
|
||||||
* default error handler, which calls exit().
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xerror(Display *dpy, XErrorEvent *ee)
|
|
||||||
{
|
|
||||||
if(ee->error_code == BadWindow
|
|
||||||
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
|
||||||
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
|
||||||
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
|
||||||
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
|
||||||
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
|
||||||
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
|
|
||||||
return 0;
|
|
||||||
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
|
||||||
ee->request_code, ee->error_code);
|
|
||||||
return xerrorxlib(dpy, ee); /* may call exit() */
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int i, j, xfd;
|
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
fd_set rd;
|
|
||||||
Bool readin = True;
|
|
||||||
Window w;
|
Window w;
|
||||||
XModifierKeymap *modmap;
|
XModifierKeymap *modmap;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
|
|
||||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
|
||||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
else if(argc != 1)
|
|
||||||
eprint("usage: dwm [-v]\n");
|
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
|
||||||
if(!dpy)
|
|
||||||
eprint("dwm: cannot open display\n");
|
|
||||||
|
|
||||||
xfd = ConnectionNumber(dpy);
|
|
||||||
screen = DefaultScreen(dpy);
|
|
||||||
root = RootWindow(dpy, screen);
|
|
||||||
|
|
||||||
otherwm = False;
|
|
||||||
XSetErrorHandler(xerrorstart);
|
|
||||||
/* this causes an error if some other window manager is running */
|
|
||||||
XSelectInput(dpy, root, SubstructureRedirectMask);
|
|
||||||
XSync(dpy, False);
|
|
||||||
|
|
||||||
if(otherwm)
|
|
||||||
eprint("dwm: another window manager is already running\n");
|
|
||||||
|
|
||||||
XSync(dpy, False);
|
|
||||||
XSetErrorHandler(NULL);
|
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
|
||||||
XSync(dpy, False);
|
|
||||||
|
|
||||||
/* init atoms */
|
/* init atoms */
|
||||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||||
@ -241,14 +120,18 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
for(ntags = 0; tags[ntags]; ntags++);
|
for(ntags = 0; tags[ntags]; ntags++);
|
||||||
seltag = emallocz(sizeof(Bool) * ntags);
|
seltag = emallocz(sizeof(Bool) * ntags);
|
||||||
seltag[DEFTAG] = True;
|
seltag[0] = True;
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
dc.bg = getcolor(BGCOLOR);
|
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||||
dc.fg = getcolor(FGCOLOR);
|
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||||
dc.border = getcolor(BORDERCOLOR);
|
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||||
|
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||||
|
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||||
|
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||||
setfont(FONT);
|
setfont(FONT);
|
||||||
|
|
||||||
|
bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
sh = DisplayHeight(dpy, screen);
|
sh = DisplayHeight(dpy, screen);
|
||||||
@ -256,7 +139,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
bx = by = 0;
|
bx = by = 0;
|
||||||
bw = sw;
|
bw = sw;
|
||||||
dc.h = bh = dc.font.height + 4;
|
dc.h = bh = dc.font.height + 2;
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
@ -268,28 +151,138 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||||
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
strcpy(stext, "dwm-"VERSION);
|
|
||||||
drawstatus();
|
|
||||||
|
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Startup Error handler to check if another window manager
|
||||||
|
* is already running.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xerrorstart(Display *dsply, XErrorEvent *ee)
|
||||||
|
{
|
||||||
|
otherwm = True;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* extern */
|
||||||
|
|
||||||
|
int
|
||||||
|
getproto(Window w)
|
||||||
|
{
|
||||||
|
int i, format, protos, status;
|
||||||
|
unsigned long extra, res;
|
||||||
|
Atom *protocols, real;
|
||||||
|
|
||||||
|
protos = 0;
|
||||||
|
status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
|
||||||
|
XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
|
||||||
|
if(status != Success || protocols == 0)
|
||||||
|
return protos;
|
||||||
|
for(i = 0; i < res; i++)
|
||||||
|
if(protocols[i] == wmatom[WMDelete])
|
||||||
|
protos |= PROTODELWIN;
|
||||||
|
free(protocols);
|
||||||
|
return protos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sendevent(Window w, Atom a, long value)
|
||||||
|
{
|
||||||
|
XEvent e;
|
||||||
|
|
||||||
|
e.type = ClientMessage;
|
||||||
|
e.xclient.window = w;
|
||||||
|
e.xclient.message_type = a;
|
||||||
|
e.xclient.format = 32;
|
||||||
|
e.xclient.data.l[0] = value;
|
||||||
|
e.xclient.data.l[1] = CurrentTime;
|
||||||
|
XSendEvent(dpy, w, False, NoEventMask, &e);
|
||||||
|
XSync(dpy, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
quit(Arg *arg)
|
||||||
|
{
|
||||||
|
readin = running = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
|
* default error handler, which calls exit().
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xerror(Display *dpy, XErrorEvent *ee)
|
||||||
|
{
|
||||||
|
if(ee->error_code == BadWindow
|
||||||
|
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
||||||
|
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
||||||
|
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
||||||
|
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
||||||
|
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
||||||
|
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
|
||||||
|
return 0;
|
||||||
|
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
||||||
|
ee->request_code, ee->error_code);
|
||||||
|
return xerrorxlib(dpy, ee); /* may call exit() */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int r, xfd;
|
||||||
|
fd_set rd;
|
||||||
|
|
||||||
|
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||||
|
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
else if(argc != 1)
|
||||||
|
eprint("usage: dwm [-v]\n");
|
||||||
|
|
||||||
|
dpy = XOpenDisplay(0);
|
||||||
|
if(!dpy)
|
||||||
|
eprint("dwm: cannot open display\n");
|
||||||
|
|
||||||
|
xfd = ConnectionNumber(dpy);
|
||||||
|
screen = DefaultScreen(dpy);
|
||||||
|
root = RootWindow(dpy, screen);
|
||||||
|
|
||||||
|
otherwm = False;
|
||||||
|
XSetErrorHandler(xerrorstart);
|
||||||
|
/* this causes an error if some other window manager is running */
|
||||||
|
XSelectInput(dpy, root, SubstructureRedirectMask);
|
||||||
|
XSync(dpy, False);
|
||||||
|
|
||||||
|
if(otherwm)
|
||||||
|
eprint("dwm: another window manager is already running\n");
|
||||||
|
|
||||||
|
XSync(dpy, False);
|
||||||
|
XSetErrorHandler(NULL);
|
||||||
|
xerrorxlib = XSetErrorHandler(xerror);
|
||||||
|
XSync(dpy, False);
|
||||||
|
|
||||||
|
setup();
|
||||||
|
drawstatus();
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
/* main event loop, also reads status text from stdin */
|
/* main event loop, also reads status text from stdin */
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
procevent();
|
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(xfd, &rd);
|
FD_SET(xfd, &rd);
|
||||||
i = select(xfd + 1, &rd, NULL, NULL, NULL);
|
r = select(xfd + 1, &rd, NULL, NULL, NULL);
|
||||||
if(i == -1 && errno == EINTR)
|
if((r == -1) && (errno == EINTR))
|
||||||
continue;
|
continue;
|
||||||
if(i < 0)
|
if(r > 0) {
|
||||||
eprint("select failed\n");
|
|
||||||
else if(i > 0) {
|
|
||||||
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)
|
||||||
@ -299,6 +292,8 @@ main(int argc, char *argv[])
|
|||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(r < 0)
|
||||||
|
eprint("select failed\n");
|
||||||
procevent();
|
procevent();
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
|
209
tag.c
209
tag.c
@ -30,98 +30,8 @@ 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
|
|
||||||
dofloat(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
|
||||||
c->ismax = False;
|
|
||||||
if(isvisible(c)) {
|
|
||||||
resize(c, True, TopLeft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ban(c);
|
|
||||||
}
|
|
||||||
if(!sel || !isvisible(sel))
|
|
||||||
sel = getnext(clients);
|
|
||||||
if(sel) {
|
|
||||||
focus(sel);
|
|
||||||
restack();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dotile(Arg *arg)
|
|
||||||
{
|
|
||||||
int h, i, n, w;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
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) {
|
|
||||||
c->ismax = False;
|
|
||||||
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))
|
|
||||||
sel = getnext(clients);
|
|
||||||
if(sel)
|
|
||||||
focus(sel);
|
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
restack();
|
|
||||||
}
|
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getnext(Client *c)
|
getnext(Client *c)
|
||||||
{
|
{
|
||||||
@ -165,84 +75,25 @@ initrregs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
|
||||||
isvisible(Client *c)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
if(c->tags[i] && seltag[i])
|
|
||||||
return True;
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
restack()
|
settags(Client *c, Client *trans)
|
||||||
{
|
{
|
||||||
static unsigned int nwins = 0;
|
char prop[512];
|
||||||
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->title;
|
|
||||||
wins[fi++] = sel->win;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wins[mi++] = sel->title;
|
|
||||||
wins[mi++] = sel->win;
|
|
||||||
}
|
|
||||||
for(c = clients; c; c = c->next)
|
|
||||||
if(isvisible(c) && c != sel) {
|
|
||||||
if(c->isfloat || arrange == dofloat) {
|
|
||||||
wins[fi++] = c->title;
|
|
||||||
wins[fi++] = c->win;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wins[mi++] = c->title;
|
|
||||||
wins[mi++] = c->win;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XRestackWindows(dpy, wins, n);
|
|
||||||
drawall();
|
|
||||||
XSync(dpy, False);
|
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
settags(Client *c)
|
|
||||||
{
|
|
||||||
char classinst[256];
|
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
Bool matched = False;
|
Bool matched = trans != NULL;
|
||||||
XClassHint ch;
|
XClassHint ch;
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
if(matched) {
|
||||||
snprintf(classinst, sizeof(classinst), "%s:%s",
|
for(i = 0; i < ntags; i++)
|
||||||
|
c->tags[i] = trans->tags[i];
|
||||||
|
}
|
||||||
|
else if(XGetClassHint(dpy, c->win, &ch)) {
|
||||||
|
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)) {
|
||||||
@ -259,6 +110,7 @@ settags(Client *c)
|
|||||||
if(!matched)
|
if(!matched)
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
c->tags[i] = seltag[i];
|
c->tags[i] = seltag[i];
|
||||||
|
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -272,15 +124,7 @@ tag(Arg *arg)
|
|||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
sel->tags[i] = False;
|
sel->tags[i] = False;
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
settitle(sel);
|
sel->weight = arg->i;
|
||||||
if(!isvisible(sel))
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
togglemode(Arg *arg)
|
|
||||||
{
|
|
||||||
arrange = arrange == dofloat ? dotile : dofloat;
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,31 +140,6 @@ toggletag(Arg *arg)
|
|||||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
settitle(sel);
|
sel->weight = (i == ntags) ? arg->i : i;
|
||||||
if(!isvisible(sel))
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 */
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
view(Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
seltag[i] = False;
|
|
||||||
seltag[arg->i] = True;
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
15
util.c
15
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +37,7 @@ erealloc(void *ptr, unsigned int size)
|
|||||||
{
|
{
|
||||||
void *res = realloc(ptr, size);
|
void *res = realloc(ptr, size);
|
||||||
if(!res)
|
if(!res)
|
||||||
bad_malloc(size);
|
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +51,13 @@ 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 -c %s'", shell, arg->cmd);
|
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
|
||||||
perror(" failed");
|
perror(" failed");
|
||||||
}
|
}
|
||||||
|
306
view.c
Normal file
306
view.c
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
/*
|
||||||
|
* (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Client *
|
||||||
|
nexttiled(Client *c)
|
||||||
|
{
|
||||||
|
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
resizecol(Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && !c->isfloat)
|
||||||
|
n++;
|
||||||
|
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(sel == getnext(clients)) {
|
||||||
|
if(mw + arg->i > sw - 100 || mw + arg->i < 100)
|
||||||
|
return;
|
||||||
|
mw += arg->i;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(mw - arg->i > sw - 100 || mw - arg->i < 100)
|
||||||
|
return;
|
||||||
|
mw -= arg->i;
|
||||||
|
}
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
restack()
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
if(!sel) {
|
||||||
|
drawstatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(sel->isfloat || arrange == dofloat) {
|
||||||
|
XRaiseWindow(dpy, sel->win);
|
||||||
|
XRaiseWindow(dpy, sel->twin);
|
||||||
|
}
|
||||||
|
if(arrange != dofloat)
|
||||||
|
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||||
|
XLowerWindow(dpy, c->twin);
|
||||||
|
XLowerWindow(dpy, c->win);
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
unsigned int n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && !c->isfloat)
|
||||||
|
n++;
|
||||||
|
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if((c = sel) == nexttiled(clients))
|
||||||
|
if(!(c = nexttiled(c->next)))
|
||||||
|
return;
|
||||||
|
detach(c);
|
||||||
|
c->next = clients;
|
||||||
|
clients->prev = c;
|
||||||
|
clients = c;
|
||||||
|
focus(c);
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
Reference in New Issue
Block a user