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
|
||||
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
||||
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
||||
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||
3cff9403766bf83a9fc2a0aef230115d68de2a8e 1.4
|
||||
|
147
client.c
147
client.c
@ -11,23 +11,55 @@
|
||||
/* static functions */
|
||||
|
||||
static void
|
||||
grabbutton(Client *c, unsigned int button, unsigned int modifier)
|
||||
detachstack(Client *c)
|
||||
{
|
||||
XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
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);
|
||||
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
|
||||
resizetitle(Client *c)
|
||||
{
|
||||
int i;
|
||||
|
||||
c->tw = textw(c->name);
|
||||
if(c->tw > c->w)
|
||||
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
|
||||
xerrordummy(Display *dsply, XErrorEvent *ee)
|
||||
{
|
||||
@ -67,22 +90,32 @@ ban(Client *c)
|
||||
void
|
||||
focus(Client *c)
|
||||
{
|
||||
Client *old = sel;
|
||||
Client *old;
|
||||
|
||||
if(!issel)
|
||||
return;
|
||||
if(!sel)
|
||||
sel = c;
|
||||
else if(sel != c) {
|
||||
if(sel->ismax)
|
||||
if(maximized)
|
||||
togglemax(NULL);
|
||||
old = sel;
|
||||
sel = c;
|
||||
grabbutton(old, AnyButton, 0);
|
||||
drawtitle(old);
|
||||
if(old) {
|
||||
grabbuttons(old, False);
|
||||
drawtitle(old);
|
||||
}
|
||||
}
|
||||
ungrabbutton(c, AnyButton, 0);
|
||||
drawtitle(c);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
if(c) {
|
||||
detachstack(c);
|
||||
c->snext = stack;
|
||||
stack = c;
|
||||
grabbuttons(c, True);
|
||||
drawtitle(c);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
|
||||
Client *
|
||||
@ -176,8 +209,7 @@ killclient(Arg *arg)
|
||||
void
|
||||
manage(Window w, XWindowAttributes *wa)
|
||||
{
|
||||
unsigned int i;
|
||||
Client *c, *tc;
|
||||
Client *c;
|
||||
Window trans;
|
||||
XSetWindowAttributes twa;
|
||||
|
||||
@ -215,32 +247,26 @@ manage(Window w, XWindowAttributes *wa)
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
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);
|
||||
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)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
c->snext = stack;
|
||||
stack = clients = c;
|
||||
|
||||
settitle(c);
|
||||
if(isvisible(c))
|
||||
sel = c;
|
||||
arrange(NULL);
|
||||
ban(c);
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapWindow(dpy, c->twin);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -325,7 +351,7 @@ void
|
||||
settitle(Client *c)
|
||||
{
|
||||
char **list = NULL;
|
||||
int i, n;
|
||||
int n;
|
||||
XTextProperty name;
|
||||
|
||||
name.nitems = 0;
|
||||
@ -353,12 +379,13 @@ void
|
||||
togglemax(Arg *arg)
|
||||
{
|
||||
int ox, oy, ow, oh;
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if((sel->ismax = !sel->ismax)) {
|
||||
if((maximized = !maximized)) {
|
||||
ox = sel->x;
|
||||
oy = sel->y;
|
||||
ow = sel->w;
|
||||
@ -369,6 +396,9 @@ togglemax(Arg *arg)
|
||||
sel->h = sh - 2 - bh;
|
||||
|
||||
restack();
|
||||
for(c = getnext(clients); c; c = getnext(c->next))
|
||||
if(c != sel)
|
||||
ban(c);
|
||||
resize(sel, arrange == dofloat, TopLeft);
|
||||
|
||||
sel->x = ox;
|
||||
@ -377,34 +407,33 @@ togglemax(Arg *arg)
|
||||
sel->h = oh;
|
||||
}
|
||||
else
|
||||
resize(sel, False, TopLeft);
|
||||
arrange(NULL);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c)
|
||||
{
|
||||
Client *nc;
|
||||
|
||||
XGrabServer(dpy);
|
||||
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);
|
||||
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);
|
||||
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
if(sel)
|
||||
focus(sel);
|
||||
arrange(NULL);
|
||||
}
|
||||
|
29
config.arg.h
29
config.arg.h
@ -4,13 +4,20 @@
|
||||
*/
|
||||
|
||||
#define TAGS \
|
||||
const char *tags[] = { "work", "net", "fnord", NULL };
|
||||
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
||||
#define BGCOLOR "#666699"
|
||||
#define FGCOLOR "#eeeeee"
|
||||
#define BORDERCOLOR "#9999CC"
|
||||
#define SELBGCOLOR "#333366"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define NORMBGCOLOR "#333333"
|
||||
#define NORMFGCOLOR "#dddddd"
|
||||
#define STATUSBGCOLOR "#222222"
|
||||
#define STATUSFGCOLOR "#9999cc"
|
||||
|
||||
#define MODKEY Mod1Mask
|
||||
#define MASTERW 60 /* percent */
|
||||
|
||||
@ -18,28 +25,36 @@ const char *tags[] = { "work", "net", "fnord", NULL };
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
{ 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, \
|
||||
{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
|
||||
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
|
||||
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
||||
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
|
||||
"done | sort -u | dmenu)\" && exec \"$exe\"" } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 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_2, tag, { .i = 1 } }, \
|
||||
{ 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_2, toggletag, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
|
@ -7,10 +7,17 @@
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "fixed"
|
||||
#define BGCOLOR "#666699"
|
||||
#define FGCOLOR "#eeeeee"
|
||||
#define BORDERCOLOR "#9999CC"
|
||||
#define SELBGCOLOR "#666699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define NORMBGCOLOR "#333366"
|
||||
#define NORMFGCOLOR "#cccccc"
|
||||
#define STATUSBGCOLOR "#dddddd"
|
||||
#define STATUSFGCOLOR "#222222"
|
||||
|
||||
#define MODKEY Mod1Mask
|
||||
#define MASTERW 60 /* percent */
|
||||
|
||||
@ -22,6 +29,8 @@ static Key key[] = { \
|
||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 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_2, tag, { .i = 1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||
@ -34,6 +43,7 @@ static Key key[] = { \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
@ -48,7 +58,7 @@ static Key key[] = { \
|
||||
};
|
||||
|
||||
/* 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 \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 1.0
|
||||
VERSION = 1.5
|
||||
|
||||
# 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
|
||||
drawtext(const char *text, Bool invert, Bool highlight)
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
||||
{
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XPoint points[5];
|
||||
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);
|
||||
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)
|
||||
return;
|
||||
@ -74,29 +61,21 @@ drawtext(const char *text, Bool invert, Bool highlight)
|
||||
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = invert ? dc.bg : dc.fg;
|
||||
gcv.background = invert ? dc.fg : dc.bg;
|
||||
gcv.foreground = col[ColFG];
|
||||
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);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
if(highlight) {
|
||||
points[0].x = dc.x + 1;
|
||||
points[0].y = dc.y + 1;
|
||||
points[1].x = dc.w - 3;
|
||||
points[1].y = 0;
|
||||
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);
|
||||
r.x = dc.x + 2;
|
||||
r.y = dc.y + 2;
|
||||
r.width = r.height = 3;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,21 +95,21 @@ void
|
||||
drawstatus()
|
||||
{
|
||||
int i, x;
|
||||
Bool istile = arrange == dotile;
|
||||
|
||||
dc.x = dc.y = 0;
|
||||
dc.w = bw;
|
||||
drawtext(NULL, !istile, False);
|
||||
|
||||
dc.w = 0;
|
||||
for(i = 0; i < ntags; i++) {
|
||||
dc.x += dc.w;
|
||||
dc.w = textw(tags[i]);
|
||||
if(istile)
|
||||
drawtext(tags[i], seltag[i], sel && sel->tags[i]);
|
||||
if(seltag[i])
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||
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;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bx + bw - dc.w;
|
||||
@ -138,11 +117,14 @@ drawstatus()
|
||||
dc.x = 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;
|
||||
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);
|
||||
XSync(dpy, False);
|
||||
@ -151,21 +133,18 @@ drawstatus()
|
||||
void
|
||||
drawtitle(Client *c)
|
||||
{
|
||||
int i;
|
||||
Bool istile = arrange == dotile;
|
||||
|
||||
if(c == sel && issel) {
|
||||
drawstatus();
|
||||
XUnmapWindow(dpy, c->twin);
|
||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||
return;
|
||||
}
|
||||
|
||||
XSetWindowBorder(dpy, c->win, dc.bg);
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||
XMapWindow(dpy, c->twin);
|
||||
dc.x = dc.y = 0;
|
||||
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);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
131
dwm.1
131
dwm.1
@ -5,10 +5,9 @@ dwm \- dynamic window manager
|
||||
.B dwm
|
||||
.RB [ \-v ]
|
||||
.SH DESCRIPTION
|
||||
.B dwm
|
||||
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
|
||||
the application in use and the task performed.
|
||||
dwm 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 the application in use and the task performed.
|
||||
.P
|
||||
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
|
||||
@ -17,16 +16,14 @@ resized and moved freely. Dialog windows are always managed floating,
|
||||
regardless of the mode selected.
|
||||
.P
|
||||
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
|
||||
tag.
|
||||
tags. Selecting certain tags displays all windows with that tag.
|
||||
.P
|
||||
.B dwm
|
||||
contains a small status bar which displays all available tags, the title
|
||||
of the focused window, and the text read from standard input. The tags of the
|
||||
focused window are highlighted.
|
||||
dwm contains a small status bar which displays all available tags, the mode,
|
||||
the title of the focused window, and the text read from standard input. The
|
||||
selected tags are highlighted with a different color, the tags of the focused
|
||||
window are highlighted with a small point.
|
||||
.P
|
||||
.B dwm
|
||||
draws a 1-pixel border around windows to indicate the focus state.
|
||||
dwm draws a 1-pixel border around windows to indicate the focus state.
|
||||
Unfocused windows contain a small bar in front of them displaying their title.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
@ -39,13 +36,17 @@ prints version information to standard output, then exits.
|
||||
is read and displayed in the status text area.
|
||||
.TP
|
||||
.B Button1
|
||||
click on a tag label views all windows with that
|
||||
.BR tag .
|
||||
click on a tag label to display all windows with that tag, click on the mode
|
||||
label toggles between tiled and floating mode.
|
||||
.TP
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that
|
||||
.B tag
|
||||
to/from the view.
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.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
|
||||
.TP
|
||||
.B Mod1-Shift-Return
|
||||
@ -53,98 +54,72 @@ Start
|
||||
.BR xterm (1).
|
||||
.TP
|
||||
.B Mod1-Tab
|
||||
Focus next
|
||||
.BR window .
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1-Shift-Tab
|
||||
Focus previous
|
||||
.BR window .
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1-Return
|
||||
Zoom current
|
||||
.B window
|
||||
to the
|
||||
.B master
|
||||
column
|
||||
.RB ( tiling
|
||||
mode only).
|
||||
Zoom current window to the master column (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-m
|
||||
Maximize current
|
||||
.BR window .
|
||||
Maximize current window.
|
||||
.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
|
||||
.B nth tag
|
||||
to current
|
||||
.BR window .
|
||||
.RB nth
|
||||
tag to current window.
|
||||
.TP
|
||||
.B Mod1-Control-Shift-[0..n]
|
||||
.B Mod1-Control-Shift-[1..n]
|
||||
Add/remove
|
||||
.B nth tag
|
||||
to/from current
|
||||
.BR window .
|
||||
.B nth
|
||||
tag to/from current window.
|
||||
.TP
|
||||
.B Mod1-Shift-c
|
||||
Close focused
|
||||
.B window.
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1-space
|
||||
Toggle between
|
||||
.B tiled
|
||||
and
|
||||
.B floating
|
||||
mode (affects
|
||||
.BR "all windows" ).
|
||||
Toggle between tiled and floating mode (affects all windows).
|
||||
.TP
|
||||
.B Mod1-[0..n]
|
||||
.B Mod1-[1..n]
|
||||
View all windows with
|
||||
.BR "tag n" .
|
||||
.BR nth
|
||||
tag.
|
||||
.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
|
||||
.B tag n
|
||||
to/from the view.
|
||||
.BR nth
|
||||
tag to/from the view.
|
||||
.TP
|
||||
.B Mod1-Shift-q
|
||||
Quit
|
||||
.B dwm.
|
||||
Quit dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
Move current
|
||||
.B window
|
||||
while dragging
|
||||
.RB ( floating
|
||||
mode only).
|
||||
Move current window while dragging (floating mode only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
Zoom current
|
||||
.B window
|
||||
to the
|
||||
.B master
|
||||
column
|
||||
.RB ( tiling
|
||||
mode only).
|
||||
Zoom current window to the master column (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
Resize current
|
||||
.B window
|
||||
while dragging
|
||||
.RB ( floating
|
||||
mode only).
|
||||
Resize current window while dragging (floating mode only).
|
||||
.SH CUSTOMIZATION
|
||||
.B dwm
|
||||
is customized by creating a custom config.h and (re)compiling the source
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH CAVEATS
|
||||
The status bar may display
|
||||
.B broken pipe
|
||||
when
|
||||
.B dwm
|
||||
has been started by
|
||||
.BR "broken pipe"
|
||||
when dwm has been started by
|
||||
.BR xdm (1),
|
||||
because it closes standard output before executing
|
||||
.BR dwm .
|
||||
because it closes standard output before executing dwm.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
|
24
dwm.h
24
dwm.h
@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };
|
||||
/* cursor */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
|
||||
/* color */
|
||||
enum { ColFG, ColBG, ColLast };
|
||||
|
||||
/* window corners */
|
||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
||||
|
||||
@ -36,9 +39,9 @@ typedef struct {
|
||||
|
||||
typedef struct { /* draw context */
|
||||
int x, y, w, h;
|
||||
unsigned long bg;
|
||||
unsigned long fg;
|
||||
unsigned long border;
|
||||
unsigned long norm[ColLast];
|
||||
unsigned long sel[ColLast];
|
||||
unsigned long status[ColLast];
|
||||
Drawable drawable;
|
||||
Fnt font;
|
||||
GC gc;
|
||||
@ -53,25 +56,25 @@ struct Client {
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int grav;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
unsigned int border, weight;
|
||||
Bool isfloat;
|
||||
Bool ismax;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
Client *prev;
|
||||
Client *snext;
|
||||
Window win;
|
||||
Window twin;
|
||||
};
|
||||
|
||||
extern const char *tags[];
|
||||
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 void (*handler[LASTEvent])(XEvent *);
|
||||
extern void (*arrange)(Arg *);
|
||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool running, issel, *seltag;
|
||||
extern Client *clients, *sel;
|
||||
extern Bool running, issel, maximized, *seltag;
|
||||
extern Client *clients, *sel, *stack;
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc;
|
||||
extern Display *dpy;
|
||||
@ -113,7 +116,7 @@ extern int xerror(Display *dsply, XErrorEvent *ee);
|
||||
extern void initrregs();
|
||||
extern Client *getnext(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 toggletag(Arg *arg);
|
||||
|
||||
@ -124,13 +127,16 @@ extern void *erealloc(void *ptr, unsigned int size);
|
||||
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> <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>
|
87
event.c
87
event.c
@ -109,50 +109,75 @@ buttonpress(XEvent *e)
|
||||
for(a.i = 0; a.i < ntags; a.i++) {
|
||||
x += textw(tags[a.i]);
|
||||
if(ev->x < x) {
|
||||
if(ev->button == Button1)
|
||||
view(&a);
|
||||
else if(ev->button == Button3)
|
||||
toggleview(&a);
|
||||
if(ev->button == Button1) {
|
||||
if(ev->state & MODKEY)
|
||||
tag(&a);
|
||||
else
|
||||
view(&a);
|
||||
}
|
||||
else if(ev->button == Button3) {
|
||||
if(ev->state & MODKEY)
|
||||
toggletag(&a);
|
||||
else
|
||||
toggleview(&a);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(ev->x < x + bmw) {
|
||||
if(ev->button == Button1)
|
||||
togglemode(NULL);
|
||||
}
|
||||
}
|
||||
else if((c = getclient(ev->window))) {
|
||||
focus(c);
|
||||
if(CLEANMASK(ev->state) == 0)
|
||||
if(maximized || CLEANMASK(ev->state) != MODKEY)
|
||||
return;
|
||||
switch(ev->button) {
|
||||
default:
|
||||
break;
|
||||
case Button1:
|
||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
movemouse(c);
|
||||
}
|
||||
break;
|
||||
case Button2:
|
||||
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
movemouse(c);
|
||||
}
|
||||
else if(ev->button == Button2)
|
||||
zoom(NULL);
|
||||
break;
|
||||
case Button3:
|
||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
resizemouse(c);
|
||||
}
|
||||
break;
|
||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
resizemouse(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
configurerequest(XEvent *e)
|
||||
{
|
||||
unsigned long newmask;
|
||||
Client *c;
|
||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XEvent synev;
|
||||
XWindowChanges wc;
|
||||
|
||||
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);
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
@ -172,20 +197,8 @@ configurerequest(XEvent *e)
|
||||
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
|
||||
if(newmask)
|
||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||
else {
|
||||
synev.type = ConfigureNotify;
|
||||
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);
|
||||
}
|
||||
else
|
||||
synconfig(c, c->x, c->y, c->w, c->h, c->border);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat)
|
||||
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];
|
||||
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;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
Bool issel = True;
|
||||
Bool maximized = False;
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
Client *stack = NULL;
|
||||
Cursor cursor[CurLast];
|
||||
Display *dpy;
|
||||
DC dc = {0};
|
||||
@ -54,6 +56,7 @@ cleanup()
|
||||
XDestroyWindow(dpy, barwin);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(dpy, False);
|
||||
free(seltag);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -121,11 +124,15 @@ setup()
|
||||
seltag[0] = True;
|
||||
|
||||
/* style */
|
||||
dc.bg = getcolor(BGCOLOR);
|
||||
dc.fg = getcolor(FGCOLOR);
|
||||
dc.border = getcolor(BORDERCOLOR);
|
||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||
setfont(FONT);
|
||||
|
||||
bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
@ -133,7 +140,7 @@ setup()
|
||||
|
||||
bx = by = 0;
|
||||
bw = sw;
|
||||
dc.h = bh = dc.font.height + 4;
|
||||
dc.h = bh = dc.font.height + 2;
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
|
25
tag.c
25
tag.c
@ -76,15 +76,19 @@ initrregs()
|
||||
}
|
||||
|
||||
void
|
||||
settags(Client *c)
|
||||
settags(Client *c, Client *trans)
|
||||
{
|
||||
char prop[512];
|
||||
unsigned int i, j;
|
||||
regmatch_t tmp;
|
||||
Bool matched = False;
|
||||
Bool matched = trans != NULL;
|
||||
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",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
ch.res_name ? ch.res_name : "", c->name);
|
||||
@ -106,6 +110,7 @@ settags(Client *c)
|
||||
if(!matched)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = seltag[i];
|
||||
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
||||
}
|
||||
|
||||
void
|
||||
@ -119,11 +124,8 @@ tag(Arg *arg)
|
||||
for(i = 0; i < ntags; i++)
|
||||
sel->tags[i] = False;
|
||||
sel->tags[arg->i] = True;
|
||||
settitle(sel);
|
||||
if(!isvisible(sel))
|
||||
arrange(NULL);
|
||||
else
|
||||
drawstatus();
|
||||
sel->weight = arg->i;
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -138,9 +140,6 @@ toggletag(Arg *arg)
|
||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||
if(i == ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
settitle(sel);
|
||||
if(!isvisible(sel))
|
||||
arrange(NULL);
|
||||
else
|
||||
drawstatus();
|
||||
sel->weight = (i == ntags) ? arg->i : i;
|
||||
arrange(NULL);
|
||||
}
|
||||
|
1
util.c
1
util.c
@ -51,6 +51,7 @@ spawn(Arg *arg)
|
||||
|
||||
if(!arg->cmd)
|
||||
return;
|
||||
/* the double-fork construct avoids zombie processes */
|
||||
if(fork() == 0) {
|
||||
if(fork() == 0) {
|
||||
if(dpy)
|
||||
|
191
view.c
191
view.c
@ -3,30 +3,83 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#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 */
|
||||
|
||||
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) {
|
||||
c->ismax = False;
|
||||
if(isvisible(c)) {
|
||||
resize(c, True, TopLeft);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
}
|
||||
if(!sel || !isvisible(sel))
|
||||
sel = getnext(clients);
|
||||
if(sel)
|
||||
focus(sel);
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
@ -36,6 +89,8 @@ 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)
|
||||
@ -47,7 +102,6 @@ dotile(Arg *arg)
|
||||
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);
|
||||
@ -86,12 +140,10 @@ dotile(Arg *arg)
|
||||
else
|
||||
ban(c);
|
||||
}
|
||||
if(!sel || !isvisible(sel))
|
||||
sel = getnext(clients);
|
||||
if(sel)
|
||||
focus(sel);
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
@ -140,53 +192,50 @@ isvisible(Client *c)
|
||||
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()
|
||||
{
|
||||
static unsigned int nwins = 0;
|
||||
static Window *wins = NULL;
|
||||
unsigned int f, fi, m, mi, n;
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
for(f = 0, m = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isfloat || arrange == dofloat)
|
||||
f++;
|
||||
else
|
||||
m++;
|
||||
}
|
||||
if(!(n = 2 * (f + m))) {
|
||||
|
||||
if(!sel) {
|
||||
drawstatus();
|
||||
return;
|
||||
}
|
||||
if(nwins < n) {
|
||||
nwins = n;
|
||||
wins = erealloc(wins, nwins * sizeof(Window));
|
||||
}
|
||||
|
||||
fi = 0;
|
||||
mi = 2 * f;
|
||||
if(sel->isfloat || arrange == dofloat) {
|
||||
wins[fi++] = sel->twin;
|
||||
wins[fi++] = sel->win;
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
XRaiseWindow(dpy, sel->twin);
|
||||
}
|
||||
else {
|
||||
wins[mi++] = sel->twin;
|
||||
wins[mi++] = sel->win;
|
||||
}
|
||||
for(c = clients; c; c = c->next)
|
||||
if(isvisible(c) && c != sel) {
|
||||
if(c->isfloat || arrange == dofloat) {
|
||||
wins[fi++] = c->twin;
|
||||
wins[fi++] = c->win;
|
||||
}
|
||||
else {
|
||||
wins[mi++] = c->twin;
|
||||
wins[mi++] = c->win;
|
||||
}
|
||||
if(arrange != dofloat)
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
XLowerWindow(dpy, c->twin);
|
||||
XLowerWindow(dpy, c->win);
|
||||
}
|
||||
XRestackWindows(dpy, wins, n);
|
||||
drawall();
|
||||
XSync(dpy, False);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
@ -211,6 +260,7 @@ toggleview(Arg *arg)
|
||||
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||
if(i == ntags)
|
||||
seltag[arg->i] = True; /* cannot toggle last view */
|
||||
reorder();
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
@ -222,32 +272,41 @@ view(Arg *arg)
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(sel == getnext(clients)) {
|
||||
if((c = getnext(sel->next)))
|
||||
sel = c;
|
||||
else
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
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);
|
||||
detach(c);
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
clients = c;
|
||||
focus(c);
|
||||
arrange(NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user