Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
0925dd588c | |||
6f20315dff | |||
2e68f22118 | |||
8aa860d270 | |||
15abade272 | |||
7ab8c87281 | |||
4ff8f71643 | |||
d22abeee86 | |||
a33150eb4b | |||
fd00b3a186 | |||
e8389a4cc0 | |||
6078d756bc | |||
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 |
5
.hgtags
5
.hgtags
@ -7,3 +7,8 @@ c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
|||||||
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
||||||
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
||||||
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
||||||
|
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||||
|
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||||
|
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||||
|
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||||
|
3cff9403766bf83a9fc2a0aef230115d68de2a8e 1.4
|
||||||
|
133
client.c
133
client.c
@ -11,23 +11,55 @@
|
|||||||
/* static functions */
|
/* static functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grabbutton(Client *c, unsigned int button, unsigned int modifier)
|
detachstack(Client *c)
|
||||||
{
|
{
|
||||||
XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK,
|
Client **tc;
|
||||||
|
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
|
||||||
|
*tc = c->snext;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
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 = textw(c->name);
|
||||||
if(c->tw > c->w)
|
if(c->tw > c->w)
|
||||||
c->tw = c->w + 2;
|
c->tw = c->w + 2;
|
||||||
@ -40,15 +72,6 @@ resizetitle(Client *c)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
ungrabbutton(Client *c, unsigned int button, unsigned int modifier)
|
|
||||||
{
|
|
||||||
XUngrabButton(dpy, button, modifier, c->win);
|
|
||||||
XUngrabButton(dpy, button, modifier | LockMask, c->win);
|
|
||||||
XUngrabButton(dpy, button, modifier | numlockmask, c->win);
|
|
||||||
XUngrabButton(dpy, button, modifier | numlockmask | LockMask, c->win);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xerrordummy(Display *dsply, XErrorEvent *ee)
|
xerrordummy(Display *dsply, XErrorEvent *ee)
|
||||||
{
|
{
|
||||||
@ -67,22 +90,32 @@ ban(Client *c)
|
|||||||
void
|
void
|
||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
Client *old = sel;
|
Client *old;
|
||||||
|
|
||||||
if(!issel)
|
if(!issel)
|
||||||
return;
|
return;
|
||||||
if(!sel)
|
if(!sel)
|
||||||
sel = c;
|
sel = c;
|
||||||
else if(sel != c) {
|
else if(sel != c) {
|
||||||
if(sel->ismax)
|
if(maximized)
|
||||||
togglemax(NULL);
|
togglemax(NULL);
|
||||||
|
old = sel;
|
||||||
sel = c;
|
sel = c;
|
||||||
grabbutton(old, AnyButton, 0);
|
if(old) {
|
||||||
|
grabbuttons(old, False);
|
||||||
drawtitle(old);
|
drawtitle(old);
|
||||||
}
|
}
|
||||||
ungrabbutton(c, AnyButton, 0);
|
}
|
||||||
|
if(c) {
|
||||||
|
detachstack(c);
|
||||||
|
c->snext = stack;
|
||||||
|
stack = c;
|
||||||
|
grabbuttons(c, True);
|
||||||
drawtitle(c);
|
drawtitle(c);
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
@ -176,8 +209,7 @@ killclient(Arg *arg)
|
|||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
Client *c;
|
||||||
Client *c, *tc;
|
|
||||||
Window trans;
|
Window trans;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
|
|
||||||
@ -215,32 +247,26 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
if(clients)
|
grabbuttons(c, False);
|
||||||
clients->prev = c;
|
settags(c, getclient(trans));
|
||||||
c->next = clients;
|
|
||||||
clients = c;
|
|
||||||
|
|
||||||
grabbutton(c, Button1, MODKEY);
|
|
||||||
grabbutton(c, Button2, MODKEY);
|
|
||||||
grabbutton(c, Button3, MODKEY);
|
|
||||||
|
|
||||||
if((tc = getclient(trans))) /* inherit tags */
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
c->tags[i] = tc->tags[i];
|
|
||||||
else
|
|
||||||
settags(c);
|
|
||||||
if(!c->isfloat)
|
if(!c->isfloat)
|
||||||
c->isfloat = trans
|
c->isfloat = trans
|
||||||
|| (c->maxw && c->minw &&
|
|| (c->maxw && c->minw &&
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
c->maxw == c->minw && c->maxh == c->minh);
|
||||||
|
|
||||||
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
|
c->next = clients;
|
||||||
|
c->snext = stack;
|
||||||
|
stack = clients = c;
|
||||||
|
|
||||||
settitle(c);
|
settitle(c);
|
||||||
if(isvisible(c))
|
ban(c);
|
||||||
sel = c;
|
|
||||||
arrange(NULL);
|
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -325,7 +351,7 @@ void
|
|||||||
settitle(Client *c)
|
settitle(Client *c)
|
||||||
{
|
{
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
int i, n;
|
int n;
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
|
|
||||||
name.nitems = 0;
|
name.nitems = 0;
|
||||||
@ -353,12 +379,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;
|
||||||
@ -369,6 +396,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;
|
||||||
@ -377,34 +407,33 @@ 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 *nc;
|
||||||
|
|
||||||
XGrabServer(dpy);
|
XGrabServer(dpy);
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
|
|
||||||
|
detach(c);
|
||||||
|
detachstack(c);
|
||||||
|
if(sel == c) {
|
||||||
|
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
||||||
|
focus(nc);
|
||||||
|
}
|
||||||
|
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
XDestroyWindow(dpy, c->twin);
|
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);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
29
config.arg.h
29
config.arg.h
@ -4,13 +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 FLOATSYMBOL "><>"
|
||||||
|
#define TILESYMBOL "[]="
|
||||||
|
|
||||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
||||||
#define BGCOLOR "#666699"
|
#define SELBGCOLOR "#333366"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define BORDERCOLOR "#9999CC"
|
#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 */
|
||||||
|
|
||||||
@ -18,28 +25,36 @@ 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 uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -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/X11R6/bin /usr/local/bin 2>/dev/null | " \
|
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
||||||
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | 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 } }, \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,10 +7,17 @@
|
|||||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
|
#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 */
|
||||||
|
|
||||||
@ -22,6 +29,8 @@ 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, 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 } }, \
|
||||||
@ -34,6 +43,7 @@ static Key key[] = { \
|
|||||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
{ 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, 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 } }, \
|
||||||
@ -48,7 +58,7 @@ static Key key[] = { \
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Query class:instance:title for regex matching info with following command:
|
/* 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) }' */
|
* 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:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 1.0
|
VERSION = 1.5
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
73
draw.c
73
draw.c
@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, Bool invert, Bool highlight)
|
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);
|
||||||
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);
|
|
||||||
XSetForeground(dpy, dc.gc, dc.border);
|
|
||||||
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
|
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
@ -74,29 +61,21 @@ drawtext(const char *text, Bool invert, Bool highlight)
|
|||||||
|
|
||||||
if(w > dc.w)
|
if(w > dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
gcv.foreground = invert ? dc.bg : dc.fg;
|
gcv.foreground = col[ColFG];
|
||||||
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);
|
||||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, 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);
|
||||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||||
}
|
}
|
||||||
if(highlight) {
|
if(highlight) {
|
||||||
points[0].x = dc.x + 1;
|
r.x = dc.x + 2;
|
||||||
points[0].y = dc.y + 1;
|
r.y = dc.y + 2;
|
||||||
points[1].x = dc.w - 3;
|
r.width = r.height = 3;
|
||||||
points[1].y = 0;
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
points[2].x = 0;
|
|
||||||
points[2].y = dc.h - 3;
|
|
||||||
points[3].x = -(dc.w - 3);
|
|
||||||
points[3].y = 0;
|
|
||||||
points[4].x = 0;
|
|
||||||
points[4].y = -(dc.h - 3);
|
|
||||||
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,21 +95,21 @@ 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], seltag[i], sel && sel->tags[i]);
|
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||||
else
|
else
|
||||||
drawtext(tags[i], !seltag[i], sel && sel->tags[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;
|
||||||
@ -138,11 +117,14 @@ drawstatus()
|
|||||||
dc.x = x;
|
dc.x = x;
|
||||||
dc.w = bw - x;
|
dc.w = bw - x;
|
||||||
}
|
}
|
||||||
drawtext(stext, !istile, False);
|
drawtext(stext, dc.status, False);
|
||||||
|
|
||||||
if(sel && ((dc.w = dc.x - x) > bh)) {
|
if((dc.w = dc.x - x) > bh) {
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
drawtext(sel->name, istile, False);
|
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);
|
||||||
@ -151,21 +133,18 @@ 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->twin);
|
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->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
dc.w = c->tw;
|
dc.w = c->tw;
|
||||||
drawtext(c->name, !istile, False);
|
drawtext(c->name, dc.norm, False);
|
||||||
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
131
dwm.1
131
dwm.1
@ -5,10 +5,9 @@ dwm \- dynamic window manager
|
|||||||
.B dwm
|
.B dwm
|
||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B dwm
|
dwm is a dynamic window manager for X. It manages windows in tiling and
|
||||||
is a dynamic window manager for X. It manages windows in tiling and floating
|
floating modes. Either mode can be applied dynamically, optimizing the
|
||||||
modes. Either mode can be applied dynamically, optimizing the environment for
|
environment for the application in use and the task performed.
|
||||||
the application in use and the task performed.
|
|
||||||
.P
|
.P
|
||||||
In tiling mode windows are managed in a master and stacking column. The master
|
In tiling mode windows are managed in a master and stacking column. The master
|
||||||
column contains the window which currently needs most attention, whereas the
|
column contains the window which currently needs most attention, whereas the
|
||||||
@ -17,16 +16,14 @@ resized and moved freely. Dialog windows are always managed floating,
|
|||||||
regardless of the mode selected.
|
regardless of the mode selected.
|
||||||
.P
|
.P
|
||||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||||
tags. Selecting a certain tag for viewing will display all windows with that
|
tags. Selecting certain tags displays all windows with that tag.
|
||||||
tag.
|
|
||||||
.P
|
.P
|
||||||
.B dwm
|
dwm contains a small status bar which displays all available tags, the mode,
|
||||||
contains a small status bar which displays all available tags, the title
|
the title of the focused window, and the text read from standard input. The
|
||||||
of the focused window, and the text read from standard input. The tags of the
|
selected tags are highlighted with a different color, the tags of the focused
|
||||||
focused window are highlighted.
|
window are highlighted with a small point.
|
||||||
.P
|
.P
|
||||||
.B dwm
|
dwm draws a 1-pixel border around windows to indicate the focus state.
|
||||||
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.
|
Unfocused windows contain a small bar in front of them displaying their title.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
@ -39,13 +36,17 @@ prints version information to standard output, then exits.
|
|||||||
is read and displayed in the status text area.
|
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 to display all windows with that tag, click on the mode
|
||||||
.BR tag .
|
label toggles between tiled and 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 tag to/from the view.
|
||||||
.B tag
|
.TP
|
||||||
to/from the view.
|
.B Mod1-Button1
|
||||||
|
click on a tag label applies that tag to the focused window.
|
||||||
|
.TP
|
||||||
|
.B Mod1-Button3
|
||||||
|
click on a tag label adds/removes that tag to/from the focused window.
|
||||||
.SS Keyboard commands
|
.SS Keyboard commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-Return
|
.B Mod1-Shift-Return
|
||||||
@ -53,98 +54,72 @@ Start
|
|||||||
.BR xterm (1).
|
.BR xterm (1).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Tab
|
.B Mod1-Tab
|
||||||
Focus next
|
Focus next window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-Tab
|
.B Mod1-Shift-Tab
|
||||||
Focus previous
|
Focus previous window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Return
|
.B Mod1-Return
|
||||||
Zoom current
|
Zoom current window to the master column (tiling mode only).
|
||||||
.B window
|
|
||||||
to the
|
|
||||||
.B master
|
|
||||||
column
|
|
||||||
.RB ( tiling
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-m
|
.B Mod1-m
|
||||||
Maximize current
|
Maximize current window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-[0..n]
|
.B Mod1-g
|
||||||
|
Grow current column (tiling mode only).
|
||||||
|
.TP
|
||||||
|
.B Mod1-s
|
||||||
|
Shrink current column (tiling mode only).
|
||||||
|
.TP
|
||||||
|
.B Mod1-Shift-[1..n]
|
||||||
Apply
|
Apply
|
||||||
.B nth tag
|
.RB nth
|
||||||
to current
|
tag to current 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
|
||||||
to/from current
|
tag to/from current window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-c
|
.B Mod1-Shift-c
|
||||||
Close focused
|
Close focused window.
|
||||||
.B window.
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-space
|
.B Mod1-space
|
||||||
Toggle between
|
Toggle between tiled and floating mode (affects all windows).
|
||||||
.B tiled
|
|
||||||
and
|
|
||||||
.B floating
|
|
||||||
mode (affects
|
|
||||||
.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 nth
|
||||||
|
tag.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Control-[0..n]
|
.B Mod1-0
|
||||||
|
View all windows with any tag.
|
||||||
|
.TP
|
||||||
|
.B Mod1-Control-[1..n]
|
||||||
Add/remove all windows with
|
Add/remove all windows with
|
||||||
.B tag n
|
.BR nth
|
||||||
to/from the view.
|
tag to/from the view.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-q
|
.B Mod1-Shift-q
|
||||||
Quit
|
Quit dwm.
|
||||||
.B dwm.
|
|
||||||
.SS Mouse commands
|
.SS Mouse commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
Move current
|
Move current window while dragging (floating mode only).
|
||||||
.B window
|
|
||||||
while dragging
|
|
||||||
.RB ( floating
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button2
|
.B Mod1-Button2
|
||||||
Zoom current
|
Zoom current window to the master column (tiling mode only).
|
||||||
.B window
|
|
||||||
to the
|
|
||||||
.B master
|
|
||||||
column
|
|
||||||
.RB ( tiling
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button3
|
.B Mod1-Button3
|
||||||
Resize current
|
Resize current window while dragging (floating mode only).
|
||||||
.B window
|
|
||||||
while dragging
|
|
||||||
.RB ( floating
|
|
||||||
mode only).
|
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
.B dwm
|
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
|
.SH CAVEATS
|
||||||
The status bar may display
|
The status bar may display
|
||||||
.B broken pipe
|
.BR "broken pipe"
|
||||||
when
|
when dwm has been started by
|
||||||
.B dwm
|
|
||||||
has been started by
|
|
||||||
.BR xdm (1),
|
.BR xdm (1),
|
||||||
because it closes standard output before executing
|
because it closes standard output before executing dwm.
|
||||||
.BR dwm .
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1)
|
.BR dmenu (1)
|
||||||
|
24
dwm.h
24
dwm.h
@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };
|
|||||||
/* cursor */
|
/* cursor */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||||
|
|
||||||
|
/* color */
|
||||||
|
enum { ColFG, ColBG, ColLast };
|
||||||
|
|
||||||
/* window corners */
|
/* window corners */
|
||||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
||||||
|
|
||||||
@ -36,9 +39,9 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct { /* 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;
|
||||||
@ -53,25 +56,25 @@ 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;
|
||||||
|
Client *snext;
|
||||||
Window win;
|
Window win;
|
||||||
Window twin;
|
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, *stack;
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc;
|
extern DC dc;
|
||||||
extern Display *dpy;
|
extern Display *dpy;
|
||||||
@ -113,7 +116,7 @@ extern int xerror(Display *dsply, XErrorEvent *ee);
|
|||||||
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 settags(Client *c);
|
extern void settags(Client *c, Client *trans);
|
||||||
extern void tag(Arg *arg);
|
extern void tag(Arg *arg);
|
||||||
extern void toggletag(Arg *arg);
|
extern void toggletag(Arg *arg);
|
||||||
|
|
||||||
@ -124,13 +127,16 @@ extern void *erealloc(void *ptr, unsigned int size);
|
|||||||
extern void spawn(Arg *arg);
|
extern void spawn(Arg *arg);
|
||||||
|
|
||||||
/* view.c */
|
/* view.c */
|
||||||
|
extern void detach(Client *c);
|
||||||
extern void dofloat(Arg *arg);
|
extern void dofloat(Arg *arg);
|
||||||
extern void dotile(Arg *arg);
|
extern void dotile(Arg *arg);
|
||||||
extern void focusnext(Arg *arg);
|
extern void focusnext(Arg *arg);
|
||||||
extern void focusprev(Arg *arg);
|
extern void focusprev(Arg *arg);
|
||||||
extern Bool isvisible(Client *c);
|
extern Bool isvisible(Client *c);
|
||||||
|
extern void resizecol(Arg *arg);
|
||||||
extern void restack();
|
extern void restack();
|
||||||
extern void togglemode(Arg *arg);
|
extern void togglemode(Arg *arg);
|
||||||
extern void toggleview(Arg *arg);
|
extern void toggleview(Arg *arg);
|
||||||
extern void view(Arg *arg);
|
extern void view(Arg *arg);
|
||||||
|
extern void viewall(Arg *arg);
|
||||||
extern void zoom(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> <a href="http://dir.gmane.org/gmane.comp.window-managers.dwm">(GMANE Archive)</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-1.0.tar.gz">dwm 1.0</a> (15kb) (20060824)</li>
|
|
||||||
<li><a href="http://10kloc.org/download/dmenu-0.5.tar.gz">dmenu 0.5</a> (7kb) (20060824)</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>
|
|
73
event.c
73
event.c
@ -109,50 +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) {
|
||||||
|
if(ev->state & MODKEY)
|
||||||
|
tag(&a);
|
||||||
|
else
|
||||||
view(&a);
|
view(&a);
|
||||||
else if(ev->button == Button3)
|
}
|
||||||
|
else if(ev->button == Button3) {
|
||||||
|
if(ev->state & MODKEY)
|
||||||
|
toggletag(&a);
|
||||||
|
else
|
||||||
toggleview(&a);
|
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);
|
||||||
if(CLEANMASK(ev->state) == 0)
|
if(maximized || CLEANMASK(ev->state) != MODKEY)
|
||||||
return;
|
return;
|
||||||
switch(ev->button) {
|
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case Button1:
|
|
||||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
|
||||||
restack(c);
|
restack(c);
|
||||||
movemouse(c);
|
movemouse(c);
|
||||||
}
|
}
|
||||||
break;
|
else if(ev->button == Button2)
|
||||||
case Button2:
|
|
||||||
zoom(NULL);
|
zoom(NULL);
|
||||||
break;
|
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
||||||
case Button3:
|
|
||||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
|
||||||
restack(c);
|
restack(c);
|
||||||
resizemouse(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;
|
||||||
@ -172,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 |
17
main.c
17
main.c
@ -19,13 +19,15 @@
|
|||||||
|
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
Bool *seltag;
|
Bool *seltag;
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
||||||
unsigned int ntags, numlockmask;
|
unsigned int ntags, numlockmask;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Bool issel = True;
|
Bool issel = True;
|
||||||
|
Bool maximized = False;
|
||||||
Client *clients = NULL;
|
Client *clients = NULL;
|
||||||
Client *sel = NULL;
|
Client *sel = NULL;
|
||||||
|
Client *stack = NULL;
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
DC dc = {0};
|
DC dc = {0};
|
||||||
@ -54,6 +56,7 @@ cleanup()
|
|||||||
XDestroyWindow(dpy, barwin);
|
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
|
||||||
@ -121,11 +124,15 @@ setup()
|
|||||||
seltag[0] = 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);
|
||||||
@ -133,7 +140,7 @@ setup()
|
|||||||
|
|
||||||
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;
|
||||||
|
21
tag.c
21
tag.c
@ -76,15 +76,19 @@ initrregs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
settags(Client *c)
|
settags(Client *c, Client *trans)
|
||||||
{
|
{
|
||||||
char prop[512];
|
char prop[512];
|
||||||
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) {
|
||||||
|
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",
|
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 : "", c->name);
|
ch.res_name ? ch.res_name : "", c->name);
|
||||||
@ -106,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
|
||||||
@ -119,11 +124,8 @@ 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);
|
arrange(NULL);
|
||||||
else
|
|
||||||
drawstatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -138,9 +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);
|
arrange(NULL);
|
||||||
else
|
|
||||||
drawstatus();
|
|
||||||
}
|
}
|
||||||
|
1
util.c
1
util.c
@ -51,6 +51,7 @@ 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)
|
||||||
|
189
view.c
189
view.c
@ -3,30 +3,83 @@
|
|||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
|
||||||
|
static Client *
|
||||||
|
minclient()
|
||||||
|
{
|
||||||
|
Client *c, *min;
|
||||||
|
|
||||||
|
if((clients && clients->isfloat) || arrange == dofloat)
|
||||||
|
return clients; /* don't touch floating order */
|
||||||
|
for(min = c = clients; c; c = c->next)
|
||||||
|
if(c->weight < min->weight)
|
||||||
|
min = c;
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
static 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 */
|
/* extern */
|
||||||
|
|
||||||
void (*arrange)(Arg *) = DEFMODE;
|
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
|
void
|
||||||
dofloat(Arg *arg)
|
dofloat(Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
maximized = False;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
c->ismax = False;
|
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
}
|
}
|
||||||
if(!sel || !isvisible(sel))
|
if(!sel || !isvisible(sel)) {
|
||||||
sel = getnext(clients);
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
if(sel)
|
focus(c);
|
||||||
focus(sel);
|
}
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +89,8 @@ dotile(Arg *arg)
|
|||||||
int h, i, n, w;
|
int h, i, n, w;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
maximized = False;
|
||||||
|
|
||||||
w = sw - mw;
|
w = sw - mw;
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(isvisible(c) && !c->isfloat)
|
if(isvisible(c) && !c->isfloat)
|
||||||
@ -47,7 +102,6 @@ dotile(Arg *arg)
|
|||||||
h = sh - bh;
|
h = sh - bh;
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
c->ismax = False;
|
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
@ -86,12 +140,10 @@ dotile(Arg *arg)
|
|||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
}
|
}
|
||||||
if(!sel || !isvisible(sel))
|
if(!sel || !isvisible(sel)) {
|
||||||
sel = getnext(clients);
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
if(sel)
|
focus(c);
|
||||||
focus(sel);
|
}
|
||||||
else
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,53 +192,50 @@ isvisible(Client *c)
|
|||||||
return False;
|
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
|
void
|
||||||
restack()
|
restack()
|
||||||
{
|
{
|
||||||
static unsigned int nwins = 0;
|
|
||||||
static Window *wins = NULL;
|
|
||||||
unsigned int f, fi, m, mi, n;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
for(f = 0, m = 0, c = clients; c; c = c->next)
|
if(!sel) {
|
||||||
if(isvisible(c)) {
|
|
||||||
if(c->isfloat || arrange == dofloat)
|
|
||||||
f++;
|
|
||||||
else
|
|
||||||
m++;
|
|
||||||
}
|
|
||||||
if(!(n = 2 * (f + m))) {
|
|
||||||
drawstatus();
|
drawstatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(nwins < n) {
|
|
||||||
nwins = n;
|
|
||||||
wins = erealloc(wins, nwins * sizeof(Window));
|
|
||||||
}
|
|
||||||
|
|
||||||
fi = 0;
|
|
||||||
mi = 2 * f;
|
|
||||||
if(sel->isfloat || arrange == dofloat) {
|
if(sel->isfloat || arrange == dofloat) {
|
||||||
wins[fi++] = sel->twin;
|
XRaiseWindow(dpy, sel->win);
|
||||||
wins[fi++] = sel->win;
|
XRaiseWindow(dpy, sel->twin);
|
||||||
}
|
}
|
||||||
else {
|
if(arrange != dofloat)
|
||||||
wins[mi++] = sel->twin;
|
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||||
wins[mi++] = sel->win;
|
XLowerWindow(dpy, c->twin);
|
||||||
|
XLowerWindow(dpy, c->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();
|
drawall();
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
@ -211,6 +260,7 @@ toggleview(Arg *arg)
|
|||||||
for(i = 0; i < ntags && !seltag[i]; i++);
|
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
seltag[arg->i] = True; /* cannot toggle last view */
|
seltag[arg->i] = True; /* cannot toggle last view */
|
||||||
|
reorder();
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,32 +272,41 @@ view(Arg *arg)
|
|||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
seltag[i] = False;
|
seltag[i] = False;
|
||||||
seltag[arg->i] = True;
|
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);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom(Arg *arg)
|
zoom(Arg *arg)
|
||||||
{
|
{
|
||||||
|
unsigned int n;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
|
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;
|
return;
|
||||||
|
|
||||||
if(sel == getnext(clients)) {
|
if((c = sel) == nexttiled(clients))
|
||||||
if((c = getnext(sel->next)))
|
if(!(c = nexttiled(c->next)))
|
||||||
sel = c;
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
}
|
detach(c);
|
||||||
|
if(clients)
|
||||||
/* pop */
|
clients->prev = c;
|
||||||
sel->prev->next = sel->next;
|
c->next = clients;
|
||||||
if(sel->next)
|
clients = c;
|
||||||
sel->next->prev = sel->prev;
|
focus(c);
|
||||||
sel->prev = NULL;
|
|
||||||
clients->prev = sel;
|
|
||||||
sel->next = clients;
|
|
||||||
clients = sel;
|
|
||||||
focus(sel);
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user