Compare commits
110 Commits
Author | SHA1 | Date | |
---|---|---|---|
2c1db7ed35 | |||
ea4827a578 | |||
55be4d6137 | |||
1f18466409 | |||
b65a1e3379 | |||
87836d79ef | |||
c8a12a0852 | |||
71b84c2114 | |||
edb2660a2e | |||
17ec726b49 | |||
373b11de11 | |||
04a2b74529 | |||
fcd98308ba | |||
b233089815 | |||
201c56f6d3 | |||
1e051d71f5 | |||
ddc79603f9 | |||
dee5ea2335 | |||
b1c9f5f144 | |||
a542bdf658 | |||
96e1b25c8c | |||
caf5a16271 | |||
936e11fd54 | |||
9715ba82aa | |||
3c35b90dd3 | |||
1d63030665 | |||
6a5b41203e | |||
fbd310972d | |||
3059c9c507 | |||
3b18f17d4d | |||
72faa1919e | |||
f8181f64e2 | |||
0045ad87df | |||
ceea528eff | |||
6c5dc7017c | |||
ae0b4fdd92 | |||
b3cea4d388 | |||
d296081321 | |||
177ed7e5de | |||
f679125206 | |||
58beead14d | |||
e1811c37ca | |||
a24a6701c8 | |||
d108cfa7fc | |||
92cb5ebb7c | |||
653826572d | |||
5a5851bac2 | |||
1d4a24dae0 | |||
a768ea93fd | |||
c95fe6e24b | |||
c75168186b | |||
3a96c9a8d5 | |||
1617b95598 | |||
726ae5bf6d | |||
3e11b38349 | |||
16ed879524 | |||
20d7b5d058 | |||
11a08b9cfc | |||
c2b753d917 | |||
6c767072a3 | |||
e9cfae7aba | |||
7ac0de8350 | |||
0b7c0f10ee | |||
51f6405b0d | |||
6096f8a113 | |||
d939f301fa | |||
8c4623da80 | |||
0faaba04a5 | |||
ec7a5ffff1 | |||
98afb7b9d0 | |||
06bae9dfb7 | |||
0b80d1842d | |||
d7ec23a5db | |||
2cf8ef9520 | |||
184471b4bb | |||
21898c6049 | |||
6a9300e815 | |||
ac24f132db | |||
cb4aa5bc35 | |||
beac539f31 | |||
b5d297f02f | |||
9056d7ea88 | |||
ebd17e4827 | |||
7e59c89250 | |||
9e4e4d9022 | |||
71fd06f843 | |||
58e6866d86 | |||
c7da124149 | |||
21bd90d7d3 | |||
c8f96b5b4c | |||
ded60365d4 | |||
629647dfee | |||
4ca3d861f0 | |||
069e7a6e24 | |||
ac6e34ea06 | |||
a308b7507a | |||
630e7ff26f | |||
3764ab471b | |||
a3319c6f8e | |||
66c699a701 | |||
aaf1e44da9 | |||
1ef2307ec4 | |||
d42c3ba2dc | |||
4b06155873 | |||
857d825eeb | |||
6b345353e3 | |||
ab3b3a8f61 | |||
71b82fb1f6 | |||
9bd9ea423e | |||
99964398e7 |
9
.hgtags
9
.hgtags
@ -24,3 +24,12 @@ a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||
719b37b37b0df829d7cf017ac70e353088fe5849 2.3
|
||||
32b246925086910d63147483160281a91a47479f 2.4
|
||||
dcbbfabc8ecc5f33a6cc950584de87da1a368045 2.5
|
||||
c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
|
||||
5308dd22b6ee8e3218c81d9e7e4125f235bb5778 2.6
|
||||
21951c0dfbae5af68ed77821a4d87253ee91803f 2.7
|
||||
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
|
||||
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
|
||||
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0
|
||||
e1c8bef05e6e48df4f26471ea0712aa43ab9d949 3.1
|
||||
4ce65f61f01b055fa6c2901c6d2527ef741aa4bf 3.2
|
||||
f2cabc83a18f9b5b548159329ddd4dee904fa31f 3.2.1
|
||||
|
4
LICENSE
4
LICENSE
@ -1,7 +1,7 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
(C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
(C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
(C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
(C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
# dwm - dynamic window manager
|
||||
# (C)opyright MMVI Anselm R. Garbe
|
||||
# (C)opyright MMVII Anselm R. Garbe
|
||||
|
||||
include config.mk
|
||||
|
||||
|
191
client.c
191
client.c
@ -1,4 +1,4 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -60,12 +60,6 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
|
||||
/* extern functions */
|
||||
|
||||
void
|
||||
ban(Client *c) {
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
XEvent synev;
|
||||
@ -85,26 +79,24 @@ configure(Client *c) {
|
||||
|
||||
void
|
||||
focus(Client *c) {
|
||||
Client *old;
|
||||
|
||||
if(!issel || (c && !isvisible(c)))
|
||||
if(c && !isvisible(c))
|
||||
return;
|
||||
if(!sel)
|
||||
sel = c;
|
||||
else if(sel != c) {
|
||||
old = sel;
|
||||
sel = c;
|
||||
if(old) {
|
||||
grabbuttons(old, False);
|
||||
drawtitle(old);
|
||||
}
|
||||
if(sel && sel != c) {
|
||||
grabbuttons(sel, False);
|
||||
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
|
||||
}
|
||||
if(c) {
|
||||
detachstack(c);
|
||||
c->snext = stack;
|
||||
stack = c;
|
||||
grabbuttons(c, True);
|
||||
drawtitle(c);
|
||||
}
|
||||
sel = c;
|
||||
drawstatus();
|
||||
if(!selscreen)
|
||||
return;
|
||||
if(c) {
|
||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
else
|
||||
@ -121,68 +113,6 @@ getclient(Window w) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Client *
|
||||
getctitle(Window w) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->twin == w)
|
||||
return c;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gravitate(Client *c, Bool invert) {
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
switch(c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case NorthGravity:
|
||||
case NorthEastGravity:
|
||||
dy = c->border;
|
||||
break;
|
||||
case EastGravity:
|
||||
case CenterGravity:
|
||||
case WestGravity:
|
||||
dy = -(c->h / 2) + c->border;
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
case SouthWestGravity:
|
||||
dy = -(c->h);
|
||||
break;
|
||||
}
|
||||
switch (c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
dx = c->border;
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
dx = -(c->w / 2) + c->border;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
dx = -(c->w + c->border);
|
||||
break;
|
||||
}
|
||||
if(invert) {
|
||||
dx = -dx;
|
||||
dy = -dy;
|
||||
}
|
||||
c->x += dx;
|
||||
c->y += dy;
|
||||
}
|
||||
|
||||
void
|
||||
killclient(Arg *arg) {
|
||||
if(!sel)
|
||||
@ -197,62 +127,59 @@ void
|
||||
manage(Window w, XWindowAttributes *wa) {
|
||||
Client *c;
|
||||
Window trans;
|
||||
XSetWindowAttributes twa;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
c->tags = emallocz(ntags * sizeof(Bool));
|
||||
c->win = w;
|
||||
c->border = 0;
|
||||
c->x = c->tx = wa->x;
|
||||
c->y = c->ty = wa->y;
|
||||
c->w = c->tw = wa->width;
|
||||
c->x = wa->x;
|
||||
c->y = wa->y;
|
||||
c->w = wa->width;
|
||||
c->h = wa->height;
|
||||
c->th = bh;
|
||||
updatesize(c);
|
||||
if(c->x + c->w + 2 * BORDERPX > sw)
|
||||
c->x = sw - c->w - 2 * BORDERPX;
|
||||
if(c->x < sx)
|
||||
if(c->w == sw && c->h == sh) {
|
||||
c->border = 0;
|
||||
c->x = sx;
|
||||
if(c->y + c->h + 2 * BORDERPX > sh)
|
||||
c->y = sh - c->h - 2 * BORDERPX;
|
||||
if(c->h != sh && c->y < bh)
|
||||
c->y = bh;
|
||||
c->y = sy;
|
||||
}
|
||||
else {
|
||||
c->border = BORDERPX;
|
||||
if(c->x + c->w + 2 * c->border > wax + waw)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(c->y + c->h + 2 * c->border > way + wah)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
if(c->x < wax)
|
||||
c->x = wax;
|
||||
if(c->y < way)
|
||||
c->y = way;
|
||||
}
|
||||
updatesizehints(c);
|
||||
c->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
twa.override_redirect = 1;
|
||||
twa.background_pixmap = ParentRelative;
|
||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||
grabbuttons(c, False);
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
|
||||
updatetitle(c);
|
||||
settags(c, getclient(trans));
|
||||
if(!c->isfloat)
|
||||
c->isfloat = trans || c->isfixed;
|
||||
resizetitle(c);
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
c->snext = stack;
|
||||
stack = clients = c;
|
||||
ban(c);
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapWindow(dpy, c->twin);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
int bottom = c->y + c->h;
|
||||
int right = c->x + c->w;
|
||||
resize(Client *c, Bool sizehints) {
|
||||
XWindowChanges wc;
|
||||
|
||||
if(c->w <= 0 || c->h <= 0)
|
||||
return;
|
||||
if(sizehints) {
|
||||
if(c->incw)
|
||||
c->w -= (c->w - c->basew) % c->incw;
|
||||
@ -267,48 +194,31 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
}
|
||||
if(sticky == TopRight || sticky == BotRight)
|
||||
c->x = right - c->w;
|
||||
if(sticky == BotLeft || sticky == BotRight)
|
||||
c->y = bottom - c->h;
|
||||
if(c->w == sw && c->h == sh)
|
||||
c->border = 0;
|
||||
else
|
||||
c->border = BORDERPX;
|
||||
/* offscreen appearance fixes */
|
||||
if(c->x + c->w < sx)
|
||||
c->x = sx;
|
||||
if(c->y + c->h < bh)
|
||||
c->y = bh;
|
||||
if(c->x > sw)
|
||||
c->x = sw - c->w;
|
||||
c->x = sw - c->w - 2 * c->border;
|
||||
if(c->y > sh)
|
||||
c->y = sh - c->h;
|
||||
resizetitle(c);
|
||||
c->y = sh - c->h - 2 * c->border;
|
||||
if(c->x + c->w + 2 * c->border < sx)
|
||||
c->x = sx;
|
||||
if(c->y + c->h + 2 * c->border < sy)
|
||||
c->y = sy;
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
wc.height = c->h;
|
||||
if(c->w == sw && c->h == sh)
|
||||
wc.border_width = 0;
|
||||
else
|
||||
wc.border_width = BORDERPX;
|
||||
wc.border_width = c->border;
|
||||
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
resizetitle(Client *c) {
|
||||
c->tw = textw(c->name);
|
||||
if(c->tw > c->w)
|
||||
c->tw = c->w + 2 * BORDERPX;
|
||||
c->tx = c->x + c->w - c->tw + 2 * BORDERPX;
|
||||
c->ty = c->y;
|
||||
if(isvisible(c))
|
||||
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
|
||||
else
|
||||
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
||||
}
|
||||
|
||||
void
|
||||
updatesize(Client *c) {
|
||||
updatesizehints(Client *c) {
|
||||
long msize;
|
||||
XSizeHints size;
|
||||
|
||||
@ -341,10 +251,6 @@ updatesize(Client *c) {
|
||||
c->minw = c->minh = 0;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
||||
c->maxw == c->minw && c->maxh == c->minh);
|
||||
if(c->flags & PWinGravity)
|
||||
c->grav = size.win_gravity;
|
||||
else
|
||||
c->grav = NorthWestGravity;
|
||||
}
|
||||
|
||||
void
|
||||
@ -387,7 +293,6 @@ unmanage(Client *c) {
|
||||
focus(nc);
|
||||
}
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
XDestroyWindow(dpy, c->twin);
|
||||
free(c->tags);
|
||||
free(c);
|
||||
XSync(dpy, False);
|
||||
|
52
config.arg.h
52
config.arg.h
@ -1,49 +1,63 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#define TAGS \
|
||||
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
|
||||
#define BORDERPX 1
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*"
|
||||
#define NORMBGCOLOR "#333333"
|
||||
#define NORMFGCOLOR "#cccccc"
|
||||
#define SELBGCOLOR "#336699"
|
||||
#define SELFGCOLOR "#dddddd"
|
||||
#define STATUSBGCOLOR "#222222"
|
||||
#define STATUSFGCOLOR "#99ccff"
|
||||
#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#333"
|
||||
#define NORMBGCOLOR "#222"
|
||||
#define NORMFGCOLOR "#ccc"
|
||||
#define SELBORDERCOLOR "#69c"
|
||||
#define SELBGCOLOR "#555"
|
||||
#define SELFGCOLOR "#fff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 40 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function argument */ \
|
||||
/* modifier key function argument */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||
{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||
{ .cmd = "exec uxterm -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
|
||||
{ MODKEY, XK_p, spawn, \
|
||||
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
|
||||
" | dmenu -font '"FONT"' -normbg '"NORMBGCOLOR"' -normfg '"NORMFGCOLOR"' " \
|
||||
"-selbg '"SELBGCOLOR"' -selfg '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
|
||||
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ 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|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ 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|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||
@ -52,17 +66,27 @@ static Key key[] = { \
|
||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||
{ MODKEY, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ 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|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "net", False }, \
|
||||
{ "Firefox.*", "3", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
{ "MPlayer.*", NULL, True }, \
|
||||
{ "Acroread.*", NULL, True }, \
|
||||
|
@ -1,24 +1,26 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#define TAGS \
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define BORDERPX 1
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "fixed"
|
||||
#define NORMBGCOLOR "#333366"
|
||||
#define NORMFGCOLOR "#cccccc"
|
||||
#define SELBGCOLOR "#666699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define STATUSBGCOLOR "#dddddd"
|
||||
#define STATUSFGCOLOR "#222222"
|
||||
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#dddddd"
|
||||
#define NORMBGCOLOR "#eeeeee"
|
||||
#define NORMFGCOLOR "#222222"
|
||||
#define SELBORDERCOLOR "#ff0000"
|
||||
#define SELBGCOLOR "#006699"
|
||||
#define SELFGCOLOR "#ffffff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 20 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
@ -30,17 +32,27 @@ static Key key[] = { \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ 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|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ 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|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||
@ -50,11 +62,19 @@ static Key key[] = { \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||
{ MODKEY, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ 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|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
@ -63,6 +83,5 @@ static Key key[] = { \
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "2", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 2.5.1
|
||||
VERSION = 3.2.2
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -20,6 +20,11 @@ LDFLAGS = ${LIBS}
|
||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
#CFLAGS += -xtarget=ultra
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
LD = ${CC}
|
||||
|
53
draw.c
53
draw.c
@ -1,10 +1,9 @@
|
||||
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMIV-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlocale.h>
|
||||
|
||||
/* static */
|
||||
|
||||
@ -98,15 +97,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
drawall(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = getnext(c->next))
|
||||
drawtitle(c);
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
drawstatus(void) {
|
||||
int i, x;
|
||||
@ -121,37 +111,20 @@ drawstatus(void) {
|
||||
dc.x += dc.w;
|
||||
}
|
||||
dc.w = bmw;
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False, False);
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bw - dc.w;
|
||||
dc.x = sw - dc.w;
|
||||
if(dc.x < x) {
|
||||
dc.x = x;
|
||||
dc.w = bw - x;
|
||||
dc.w = sw - x;
|
||||
}
|
||||
drawtext(stext, dc.status, False, False);
|
||||
drawtext(stext, dc.norm, False, False);
|
||||
if((dc.w = dc.x - x) > bh) {
|
||||
dc.x = x;
|
||||
drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False);
|
||||
}
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
drawtitle(Client *c) {
|
||||
if(c == sel && issel) {
|
||||
drawstatus();
|
||||
XUnmapWindow(dpy, c->twin);
|
||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||
return;
|
||||
}
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||
XMapWindow(dpy, c->twin);
|
||||
dc.x = dc.y = 0;
|
||||
dc.w = c->tw;
|
||||
drawtext(c->name, dc.norm, False,False);
|
||||
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
@ -167,11 +140,10 @@ getcolor(const char *colstr) {
|
||||
|
||||
void
|
||||
setfont(const char *fontstr) {
|
||||
char **missing, *def;
|
||||
char *def, **missing;
|
||||
int i, n;
|
||||
|
||||
missing = NULL;
|
||||
setlocale(LC_ALL, "");
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
@ -179,10 +151,6 @@ setfont(const char *fontstr) {
|
||||
while(n--)
|
||||
fprintf(stderr, "missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
if(dc.font.set) {
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = NULL;
|
||||
}
|
||||
}
|
||||
if(dc.font.set) {
|
||||
XFontSetExtents *font_extents;
|
||||
@ -203,11 +171,8 @@ setfont(const char *fontstr) {
|
||||
if(dc.font.xfont)
|
||||
XFreeFont(dpy, dc.font.xfont);
|
||||
dc.font.xfont = NULL;
|
||||
dc.font.xfont = XLoadQueryFont(dpy, fontstr);
|
||||
if (!dc.font.xfont)
|
||||
dc.font.xfont = XLoadQueryFont(dpy, "fixed");
|
||||
if (!dc.font.xfont)
|
||||
eprint("error, cannot init 'fixed' font\n");
|
||||
if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
|
||||
eprint("error, cannot load font: '%s'\n", fontstr);
|
||||
dc.font.ascent = dc.font.xfont->ascent;
|
||||
dc.font.descent = dc.font.xfont->descent;
|
||||
}
|
||||
|
35
dwm.1
35
dwm.1
@ -10,10 +10,10 @@ 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 area. The master
|
||||
area contains the window which currently needs most attention, whereas the
|
||||
area contains the windows which currently need most attention, whereas the
|
||||
stacking area contains all other windows. In floating mode windows can be
|
||||
resized and moved freely. Dialog windows are always managed floating,
|
||||
regardless of the mode selected.
|
||||
regardless of the mode applied.
|
||||
.P
|
||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||
tags. Selecting certain tags displays all windows with these tags.
|
||||
@ -22,11 +22,10 @@ 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 indicated with a different color. The tags of the focused
|
||||
window are indicated with a filled square in the top left corner. The tags
|
||||
which are applied to one or more clients are indicated with an empty square in
|
||||
which are applied to one or more windows are indicated with an empty square in
|
||||
the top left corner.
|
||||
.P
|
||||
dwm draws a 1-pixel border around windows to indicate the focus state.
|
||||
Unfocused windows contain a small bar in front of them displaying their title.
|
||||
dwm draws a small border around windows to indicate the focus state.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-v
|
||||
@ -44,6 +43,12 @@ label toggles between tiling and floating mode.
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Button4
|
||||
click on the mode label increases the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Button5
|
||||
click on the mode label decreases the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
@ -70,6 +75,12 @@ Grow master area (tiling mode only).
|
||||
.B Mod1-s
|
||||
Shrink master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-i
|
||||
Increase the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-d
|
||||
Decrease the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Shift-[1..n]
|
||||
Apply
|
||||
.RB nth
|
||||
@ -122,9 +133,17 @@ 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
|
||||
.BR "broken pipe"
|
||||
when dwm has been started by
|
||||
.BR "EOF"
|
||||
when dwm has been started by an X session manager like
|
||||
.BR xdm (1),
|
||||
because it closes standard output before executing dwm.
|
||||
because those close standard output before executing dwm.
|
||||
.P
|
||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||
JDK 1.6 versions, because it assumes a reparenting window manager. As a workaround
|
||||
you can use JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or you
|
||||
can set the following environment variable (to use the older Motif
|
||||
backend instead):
|
||||
.BR AWT_TOOLKIT=MToolkit .
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
|
34
dwm.h
34
dwm.h
@ -1,4 +1,4 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* dynamic window manager is designed like any other X client as well. It is
|
||||
@ -37,17 +37,12 @@
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
/* other stuff used in different places */
|
||||
#define BORDERPX 1
|
||||
#define PROTODELWIN 1
|
||||
|
||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef enum {
|
||||
TopLeft, TopRight, BotLeft, BotRight
|
||||
} Corner; /* window corners */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef union {
|
||||
const char *cmd;
|
||||
@ -66,7 +61,6 @@ typedef struct {
|
||||
int x, y, w, h;
|
||||
unsigned long norm[ColLast];
|
||||
unsigned long sel[ColLast];
|
||||
unsigned long status[ColLast];
|
||||
Drawable drawable;
|
||||
Fnt font;
|
||||
GC gc;
|
||||
@ -78,9 +72,7 @@ struct Client {
|
||||
int proto;
|
||||
int x, y, w, h;
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int tx, ty, tw, th; /* title window geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int grav;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
@ -89,19 +81,19 @@ struct Client {
|
||||
Client *prev;
|
||||
Client *snext;
|
||||
Window win;
|
||||
Window twin;
|
||||
};
|
||||
|
||||
extern const char *tags[]; /* all tags */
|
||||
extern char stext[1024]; /* status text */
|
||||
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
||||
extern char stext[256]; /* status text */
|
||||
extern int bh, bmw; /* bar height, bar mode label width */
|
||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
|
||||
extern unsigned int master, nmaster; /* master percent, number of master clients */
|
||||
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool running, issel, *seltag; /* seltag is array of Bool */
|
||||
extern Bool running, selscreen, *seltag; /* seltag is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc; /* global draw context */
|
||||
@ -109,24 +101,18 @@ extern Display *dpy;
|
||||
extern Window root, barwin;
|
||||
|
||||
/* client.c */
|
||||
extern void ban(Client *c); /* ban c from screen */
|
||||
extern void configure(Client *c); /* send synthetic configure event */
|
||||
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||
extern Client *getclient(Window w); /* return client of w */
|
||||
extern Client *getctitle(Window w); /* return client of title window */
|
||||
extern void gravitate(Client *c, Bool invert); /* gravitate c */
|
||||
extern void killclient(Arg *arg); /* kill c nicely */
|
||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
|
||||
extern void resizetitle(Client *c); /* resizes c->twin correctly */
|
||||
extern void updatesize(Client *c); /* update the size structs of c */
|
||||
extern void resize(Client *c, Bool sizehints); /* resize c*/
|
||||
extern void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
extern void updatetitle(Client *c); /* update the name of c */
|
||||
extern void unmanage(Client *c); /* destroy c */
|
||||
|
||||
/* draw.c */
|
||||
extern void drawall(void); /* draw all visible client titles and the bar */
|
||||
extern void drawstatus(void); /* draw the bar */
|
||||
extern void drawtitle(Client *c); /* draw title of c */
|
||||
extern unsigned long getcolor(const char *colstr); /* return color of colstr */
|
||||
extern void setfont(const char *fontstr); /* set the font for DC */
|
||||
extern unsigned int textw(const char *text); /* return the width of text in px*/
|
||||
@ -152,7 +138,6 @@ extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
|
||||
/* util.c */
|
||||
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
|
||||
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||
extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
|
||||
extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
|
||||
|
||||
/* view.c */
|
||||
@ -161,6 +146,7 @@ extern void dofloat(void); /* arranges all windows floating */
|
||||
extern void dotile(void); /* arranges all windows tiled */
|
||||
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
|
||||
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
|
||||
extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
|
||||
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
||||
extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
|
||||
extern void restack(void); /* restores z layers of all clients */
|
||||
|
90
event.c
90
event.c
@ -1,4 +1,4 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -35,14 +35,16 @@ movemouse(Client *c) {
|
||||
c->ismax = False;
|
||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
@ -50,13 +52,13 @@ movemouse(Client *c) {
|
||||
c->y = ocy + (ev.xmotion.y - y1);
|
||||
if(abs(wax + c->x) < SNAP)
|
||||
c->x = wax;
|
||||
else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * BORDERPX;
|
||||
else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(abs(way - c->y) < SNAP)
|
||||
c->y = way;
|
||||
else if(abs((way + wah) - (c->y + c->h)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * BORDERPX;
|
||||
resize(c, False, TopLeft);
|
||||
else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
resize(c, False);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -66,7 +68,6 @@ static void
|
||||
resizemouse(Client *c) {
|
||||
int ocx, ocy;
|
||||
int nw, nh;
|
||||
Corner sticky;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
@ -75,30 +76,26 @@ resizemouse(Client *c) {
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
c->ismax = False;
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
||||
switch(ev.type) {
|
||||
case ButtonRelease:
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
if((nw = abs(ocx - ev.xmotion.x)))
|
||||
c->w = nw;
|
||||
if((nh = abs(ocy - ev.xmotion.y)))
|
||||
c->h = nh;
|
||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||
if(ocx <= ev.xmotion.x)
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
||||
else
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
||||
resize(c, True, sticky);
|
||||
nw = ev.xmotion.x - ocx - 2 * c->border + 1;
|
||||
c->w = nw > 0 ? nw : 1;
|
||||
nh = ev.xmotion.y - ocy - 2 * c->border + 1;
|
||||
c->h = nh > 0 ? nh : 1;
|
||||
resize(c, True);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -131,8 +128,20 @@ buttonpress(XEvent *e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if((ev->x < x + bmw) && (ev->button == Button1))
|
||||
togglemode(NULL);
|
||||
if(ev->x < x + bmw)
|
||||
switch(ev->button) {
|
||||
case Button1:
|
||||
togglemode(NULL);
|
||||
break;
|
||||
case Button4:
|
||||
a.i = 1;
|
||||
incnmaster(&a);
|
||||
break;
|
||||
case Button5:
|
||||
a.i = -1;
|
||||
incnmaster(&a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((c = getclient(ev->window))) {
|
||||
focus(c);
|
||||
@ -161,7 +170,6 @@ configurerequest(XEvent *e) {
|
||||
|
||||
if((c = getclient(ev->window))) {
|
||||
c->ismax = False;
|
||||
gravitate(c, True);
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
@ -172,7 +180,6 @@ configurerequest(XEvent *e) {
|
||||
c->h = ev->height;
|
||||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
gravitate(c, False);
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
@ -184,9 +191,9 @@ configurerequest(XEvent *e) {
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat) {
|
||||
resize(c, False, TopLeft);
|
||||
resize(c, False);
|
||||
if(!isvisible(c))
|
||||
ban(c);
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
else
|
||||
arrange();
|
||||
@ -220,25 +227,22 @@ enternotify(XEvent *e) {
|
||||
|
||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||
return;
|
||||
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
|
||||
if((c = getclient(ev->window)) && isvisible(c))
|
||||
focus(c);
|
||||
else if(ev->window == root) {
|
||||
issel = True;
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
drawall();
|
||||
selscreen = True;
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
expose(XEvent *e) {
|
||||
Client *c;
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
|
||||
if(ev->count == 0) {
|
||||
if(barwin == ev->window)
|
||||
drawstatus();
|
||||
else if((c = getctitle(ev->window)))
|
||||
drawtitle(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,8 +269,8 @@ leavenotify(XEvent *e) {
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
|
||||
if((ev->window == root) && !ev->same_screen) {
|
||||
issel = False;
|
||||
drawall();
|
||||
selscreen = False;
|
||||
focus(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,13 +320,13 @@ propertynotify(XEvent *e) {
|
||||
arrange();
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
updatesize(c);
|
||||
updatesizehints(c);
|
||||
break;
|
||||
}
|
||||
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||
updatetitle(c);
|
||||
resizetitle(c);
|
||||
drawtitle(c);
|
||||
if(c == sel)
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
40
main.c
40
main.c
@ -1,9 +1,10 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include "dwm.h"
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -16,13 +17,13 @@
|
||||
|
||||
/* extern */
|
||||
|
||||
char stext[1024];
|
||||
char stext[256];
|
||||
Bool *seltag;
|
||||
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, ntags, numlockmask;
|
||||
int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, nmaster, ntags, numlockmask;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
Bool issel = True;
|
||||
Bool selscreen = True;
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
Client *stack = NULL;
|
||||
@ -39,9 +40,9 @@ static Bool otherwm, readin;
|
||||
static void
|
||||
cleanup(void) {
|
||||
close(STDIN_FILENO);
|
||||
while(sel) {
|
||||
resize(sel, True, TopLeft);
|
||||
unmanage(sel);
|
||||
while(stack) {
|
||||
resize(stack, True);
|
||||
unmanage(stack);
|
||||
}
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
@ -51,6 +52,9 @@ cleanup(void) {
|
||||
XFreePixmap(dpy, dc.drawable);
|
||||
XFreeGC(dpy, dc.gc);
|
||||
XDestroyWindow(dpy, barwin);
|
||||
XFreeCursor(dpy, cursor[CurNormal]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(dpy, False);
|
||||
free(seltag);
|
||||
@ -97,6 +101,7 @@ setup(void) {
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
/* init modifier map */
|
||||
numlockmask = 0;
|
||||
modmap = XGetModifierMapping(dpy);
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||
@ -104,7 +109,7 @@ setup(void) {
|
||||
numlockmask = (1 << i);
|
||||
}
|
||||
}
|
||||
XFree(modmap);
|
||||
XFreeModifiermap(modmap);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask;
|
||||
@ -116,28 +121,26 @@ setup(void) {
|
||||
seltag = emallocz(sizeof(Bool) * ntags);
|
||||
seltag[0] = True;
|
||||
/* style */
|
||||
dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
|
||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||
dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
|
||||
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||
setfont(FONT);
|
||||
/* geometry */
|
||||
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
master = MASTER;
|
||||
nmaster = NMASTER;
|
||||
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||
/* bar */
|
||||
bx = sx;
|
||||
by = sy;
|
||||
bw = sw;
|
||||
dc.h = bh = dc.font.height + 2;
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
|
||||
barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
@ -153,7 +156,7 @@ setup(void) {
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
/* multihead support */
|
||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -232,11 +235,12 @@ main(int argc, char *argv[]) {
|
||||
fd_set rd;
|
||||
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
setlocale(LC_CTYPE, "");
|
||||
dpy = XOpenDisplay(0);
|
||||
if(!dpy)
|
||||
eprint("dwm: cannot open display\n");
|
||||
|
2
tag.c
2
tag.c
@ -1,4 +1,4 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
11
util.c
11
util.c
@ -1,4 +1,4 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -29,15 +29,6 @@ eprint(const char *errstr, ...) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void *
|
||||
erealloc(void *ptr, unsigned int size) {
|
||||
void *res = realloc(ptr, size);
|
||||
|
||||
if(!res)
|
||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
spawn(Arg *arg) {
|
||||
static char *shell = NULL;
|
||||
|
85
view.c
85
view.c
@ -1,7 +1,8 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* static */
|
||||
|
||||
@ -30,7 +31,7 @@ togglemax(Client *c) {
|
||||
c->w = c->rw;
|
||||
c->h = c->rh;
|
||||
}
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
@ -55,10 +56,10 @@ dofloat(void) {
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
@ -69,48 +70,46 @@ dofloat(void) {
|
||||
|
||||
void
|
||||
dotile(void) {
|
||||
unsigned int i, n, mpx, stackw, th;
|
||||
unsigned int i, n, mw, mh, tw, th;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
mpx = (waw * master) / 1000;
|
||||
stackw = waw - mpx;
|
||||
/* window geoms */
|
||||
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
|
||||
mw = (n > nmaster) ? (waw * master) / 1000 : waw;
|
||||
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
||||
tw = waw - mw;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isfloat) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
continue;
|
||||
}
|
||||
c->ismax = False;
|
||||
c->x = wax;
|
||||
c->y = way;
|
||||
if(n == 1) { /* only 1 window */
|
||||
c->w = waw - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else if(i == 0) { /* master window */
|
||||
c->w = mpx - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
th = wah / (n - 1);
|
||||
if(i < nmaster) {
|
||||
c->y += i * mh;
|
||||
c->w = mw - 2 * BORDERPX;
|
||||
c->h = mh - 2 * BORDERPX;
|
||||
}
|
||||
else { /* tile window */
|
||||
c->x += mpx;
|
||||
c->w = stackw - 2 * BORDERPX;
|
||||
if(th > bh) {
|
||||
c->y += (i - 1) * th;
|
||||
c->x += mw;
|
||||
c->w = tw - 2 * BORDERPX;
|
||||
if(th - 2 * BORDERPX > bh) {
|
||||
c->y += (i - nmaster) * th;
|
||||
c->h = th - 2 * BORDERPX;
|
||||
}
|
||||
else /* fallback if th < bh */
|
||||
else /* fallback if th - 2 * BORDERPX < bh */
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
resize(c, False);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
@ -148,6 +147,18 @@ focusprev(Arg *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(Arg *arg) {
|
||||
if((arrange == dofloat) || (nmaster + arg->i < 1)
|
||||
|| (wah / (nmaster + arg->i) - 2 * BORDERPX < bh))
|
||||
return;
|
||||
nmaster += arg->i;
|
||||
if(sel)
|
||||
arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
Bool
|
||||
isvisible(Client *c) {
|
||||
unsigned int i;
|
||||
@ -163,7 +174,8 @@ resizemaster(Arg *arg) {
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(master + arg->i > 950 || master + arg->i < 50)
|
||||
if(waw * (master + arg->i) / 1000 > waw - bh - 2 * BORDERPX
|
||||
|| waw * (master + arg->i) / 1000 < bh + 2 * BORDERPX)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
@ -175,27 +187,20 @@ restack(void) {
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel) {
|
||||
drawstatus();
|
||||
drawstatus();
|
||||
if(!sel)
|
||||
return;
|
||||
}
|
||||
if(sel->isfloat || arrange == dofloat) {
|
||||
if(sel->isfloat || arrange == dofloat)
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
XRaiseWindow(dpy, sel->twin);
|
||||
}
|
||||
if(arrange != dofloat) {
|
||||
if(!sel->isfloat) {
|
||||
XLowerWindow(dpy, sel->twin);
|
||||
if(!sel->isfloat)
|
||||
XLowerWindow(dpy, sel->win);
|
||||
}
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
if(c == sel)
|
||||
continue;
|
||||
XLowerWindow(dpy, c->twin);
|
||||
XLowerWindow(dpy, c->win);
|
||||
}
|
||||
}
|
||||
drawall();
|
||||
XSync(dpy, False);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
@ -250,11 +255,9 @@ zoom(Arg *arg) {
|
||||
togglemax(sel);
|
||||
return;
|
||||
}
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c) && !c->isfloat)
|
||||
n++;
|
||||
if(n < 2 || (arrange == dofloat))
|
||||
return;
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
return;
|
||||
|
Reference in New Issue
Block a user