Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
db98a7d60f | |||
0464e42231 | |||
4970ef938e | |||
f85b163899 | |||
2b66f7afb1 | |||
67b3083dfd | |||
0c7bcc24cb | |||
98c6a92eb5 | |||
ba59bc8b9f | |||
cd8d8e1208 | |||
04eb016e78 | |||
0a4342098b | |||
72707c2fae | |||
06dc514bc7 | |||
2b5553b1eb | |||
4688ad181d | |||
dc5d967ee6 | |||
fe3756c8e1 |
1
.hgtags
1
.hgtags
@ -1,3 +1,4 @@
|
|||||||
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
||||||
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
||||||
7e66082e5092fb0bccd18a3695a0bec52c80fdb2 0.3
|
7e66082e5092fb0bccd18a3695a0bec52c80fdb2 0.3
|
||||||
|
eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
||||||
|
12
README
12
README
@ -1,6 +1,5 @@
|
|||||||
dwm - dynamic window manager
|
dwm - dynamic window manager
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
dwm is an extremly fast, small, and dynamic X11 window manager.
|
dwm is an extremly fast, small, and dynamic X11 window manager.
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +33,17 @@ the DISPLAY environment variable is set correctly, e.g.:
|
|||||||
This will start dwm on display :1 of the host foo.bar.
|
This will start dwm on display :1 of the host foo.bar.
|
||||||
|
|
||||||
|
|
||||||
|
Displaying status info
|
||||||
|
----------------------
|
||||||
|
In order to display status info in the bar, you can do following
|
||||||
|
in .xinitrc:
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
echo `date` `uptime | sed 's/.*://; s/,//g'`
|
||||||
|
sleep 2
|
||||||
|
done | dwm
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
The configuration of dwm is done by customizing source code,
|
The configuration of dwm is done by customizing source code,
|
||||||
|
153
client.c
153
client.c
@ -70,11 +70,13 @@ focusnext(Arg *arg)
|
|||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(sel->ismax)
|
||||||
|
togglemax(NULL);
|
||||||
|
|
||||||
if(!(c = getnext(sel->next, tsel)))
|
if(!(c = getnext(sel->next, tsel)))
|
||||||
c = getnext(clients, tsel);
|
c = getnext(clients, tsel);
|
||||||
if(c) {
|
if(c) {
|
||||||
higher(c);
|
higher(c);
|
||||||
c->revert = sel;
|
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +89,14 @@ focusprev(Arg *arg)
|
|||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
|
if(sel->ismax)
|
||||||
|
togglemax(NULL);
|
||||||
|
|
||||||
|
if(!(c = getprev(sel->prev))) {
|
||||||
|
for(c = clients; c && c->next; c = c->next);
|
||||||
|
c = getprev(c);
|
||||||
|
}
|
||||||
|
if(c) {
|
||||||
higher(c);
|
higher(c);
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
@ -97,6 +106,7 @@ Client *
|
|||||||
getclient(Window w)
|
getclient(Window w)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
if(c->win == w)
|
if(c->win == w)
|
||||||
return c;
|
return c;
|
||||||
@ -107,6 +117,7 @@ Client *
|
|||||||
getctitle(Window w)
|
getctitle(Window w)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
if(c->title == w)
|
if(c->title == w)
|
||||||
return c;
|
return c;
|
||||||
@ -119,6 +130,8 @@ gravitate(Client *c, Bool invert)
|
|||||||
int dx = 0, dy = 0;
|
int dx = 0, dy = 0;
|
||||||
|
|
||||||
switch(c->grav) {
|
switch(c->grav) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
case StaticGravity:
|
case StaticGravity:
|
||||||
case NorthWestGravity:
|
case NorthWestGravity:
|
||||||
case NorthGravity:
|
case NorthGravity:
|
||||||
@ -135,11 +148,11 @@ gravitate(Client *c, Bool invert)
|
|||||||
case SouthWestGravity:
|
case SouthWestGravity:
|
||||||
dy = -(c->h);
|
dy = -(c->h);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c->grav) {
|
switch (c->grav) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
case StaticGravity:
|
case StaticGravity:
|
||||||
case NorthWestGravity:
|
case NorthWestGravity:
|
||||||
case WestGravity:
|
case WestGravity:
|
||||||
@ -156,8 +169,6 @@ gravitate(Client *c, Bool invert)
|
|||||||
case SouthEastGravity:
|
case SouthEastGravity:
|
||||||
dx = -(c->w + c->border);
|
dx = -(c->w + c->border);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(invert) {
|
if(invert) {
|
||||||
@ -196,10 +207,9 @@ lower(Client *c)
|
|||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
int diff;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XSetWindowAttributes twa;
|
|
||||||
Window trans;
|
Window trans;
|
||||||
|
XSetWindowAttributes twa;
|
||||||
|
|
||||||
c = emallocz(sizeof(Client));
|
c = emallocz(sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
@ -216,7 +226,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
setsize(c);
|
setsize(c);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
twa.override_redirect = 1;
|
twa.override_redirect = 1;
|
||||||
twa.background_pixmap = ParentRelative;
|
twa.background_pixmap = ParentRelative;
|
||||||
@ -229,11 +239,11 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
|
|
||||||
settags(c);
|
settags(c);
|
||||||
|
|
||||||
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
|
|
||||||
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
|
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
|
||||||
XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
|
||||||
@ -258,59 +268,55 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
else {
|
else {
|
||||||
XMapRaised(dpy, c->win);
|
XMapRaised(dpy, c->win);
|
||||||
XMapRaised(dpy, c->title);
|
XMapRaised(dpy, c->title);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
}
|
||||||
maximize(Arg *arg)
|
|
||||||
{
|
|
||||||
if(!sel)
|
|
||||||
return;
|
|
||||||
sel->x = sx;
|
|
||||||
sel->y = sy + bh;
|
|
||||||
sel->w = sw - 2 * sel->border;
|
|
||||||
sel->h = sh - 2 * sel->border - bh;
|
|
||||||
higher(sel);
|
|
||||||
resize(sel, False, TopLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pop(Client *c)
|
pop(Client *c)
|
||||||
{
|
{
|
||||||
Client **l;
|
Client **l;
|
||||||
|
|
||||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
||||||
|
if(c->prev)
|
||||||
|
c->prev->next = c->next;
|
||||||
|
if(c->next)
|
||||||
|
c->next->prev = c->prev;
|
||||||
*l = c->next;
|
*l = c->next;
|
||||||
|
|
||||||
c->next = clients; /* pop */
|
c->prev = NULL;
|
||||||
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resize(Client *c, Bool inc, Corner sticky)
|
resize(Client *c, Bool sizehints, Corner sticky)
|
||||||
{
|
{
|
||||||
XConfigureEvent e;
|
|
||||||
int right = c->x + c->w;
|
|
||||||
int bottom = c->y + c->h;
|
int bottom = c->y + c->h;
|
||||||
|
int right = c->x + c->w;
|
||||||
|
XConfigureEvent e;
|
||||||
|
|
||||||
if(inc) {
|
if(sizehints) {
|
||||||
if(c->incw)
|
if(c->incw)
|
||||||
c->w -= (c->w - c->basew) % c->incw;
|
c->w -= (c->w - c->basew) % c->incw;
|
||||||
if(c->inch)
|
if(c->inch)
|
||||||
c->h -= (c->h - c->baseh) % c->inch;
|
c->h -= (c->h - c->baseh) % c->inch;
|
||||||
|
if(c->minw && c->w < c->minw)
|
||||||
|
c->w = c->minw;
|
||||||
|
if(c->minh && c->h < c->minh)
|
||||||
|
c->h = c->minh;
|
||||||
|
if(c->maxw && c->w > c->maxw)
|
||||||
|
c->w = c->maxw;
|
||||||
|
if(c->maxh && c->h > c->maxh)
|
||||||
|
c->h = c->maxh;
|
||||||
}
|
}
|
||||||
if(c->x > sw) /* might happen on restart */
|
if(c->x > sw) /* might happen on restart */
|
||||||
c->x = sw - c->w;
|
c->x = sw - c->w;
|
||||||
if(c->y > sh)
|
if(c->y > sh)
|
||||||
c->y = sh - c->h;
|
c->y = sh - c->h;
|
||||||
if(c->minw && c->w < c->minw)
|
|
||||||
c->w = c->minw;
|
|
||||||
if(c->minh && c->h < c->minh)
|
|
||||||
c->h = c->minh;
|
|
||||||
if(c->maxw && c->w > c->maxw)
|
|
||||||
c->w = c->maxw;
|
|
||||||
if(c->maxh && c->h > c->maxh)
|
|
||||||
c->h = c->maxh;
|
|
||||||
if(sticky == TopRight || sticky == BotRight)
|
if(sticky == TopRight || sticky == BotRight)
|
||||||
c->x = right - c->w;
|
c->x = right - c->w;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
if(sticky == BotLeft || sticky == BotRight)
|
||||||
@ -337,8 +343,9 @@ resize(Client *c, Bool inc, Corner sticky)
|
|||||||
void
|
void
|
||||||
setsize(Client *c)
|
setsize(Client *c)
|
||||||
{
|
{
|
||||||
XSizeHints size;
|
|
||||||
long msize;
|
long msize;
|
||||||
|
XSizeHints size;
|
||||||
|
|
||||||
if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
|
if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
|
||||||
size.flags = PSize;
|
size.flags = PSize;
|
||||||
c->flags = size.flags;
|
c->flags = size.flags;
|
||||||
@ -375,9 +382,9 @@ setsize(Client *c)
|
|||||||
void
|
void
|
||||||
settitle(Client *c)
|
settitle(Client *c)
|
||||||
{
|
{
|
||||||
XTextProperty name;
|
|
||||||
int n;
|
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
|
int n;
|
||||||
|
XTextProperty name;
|
||||||
|
|
||||||
name.nitems = 0;
|
name.nitems = 0;
|
||||||
c->name[0] = 0;
|
c->name[0] = 0;
|
||||||
@ -400,6 +407,38 @@ settitle(Client *c)
|
|||||||
resizetitle(c);
|
resizetitle(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglemax(Arg *arg)
|
||||||
|
{
|
||||||
|
int ox, oy, ow, oh;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if((sel->ismax = !sel->ismax)) {
|
||||||
|
ox = sel->x;
|
||||||
|
oy = sel->y;
|
||||||
|
ow = sel->w;
|
||||||
|
oh = sel->h;
|
||||||
|
sel->x = sx;
|
||||||
|
sel->y = sy + bh;
|
||||||
|
sel->w = sw - 2 * sel->border;
|
||||||
|
sel->h = sh - 2 * sel->border - bh;
|
||||||
|
|
||||||
|
higher(sel);
|
||||||
|
resize(sel, False, TopLeft);
|
||||||
|
|
||||||
|
sel->x = ox;
|
||||||
|
sel->y = oy;
|
||||||
|
sel->w = ow;
|
||||||
|
sel->h = oh;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resize(sel, False, TopLeft);
|
||||||
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unmanage(Client *c)
|
unmanage(Client *c)
|
||||||
{
|
{
|
||||||
@ -412,13 +451,18 @@ unmanage(Client *c)
|
|||||||
XDestroyWindow(dpy, c->title);
|
XDestroyWindow(dpy, c->title);
|
||||||
|
|
||||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
||||||
|
if(c->prev)
|
||||||
|
c->prev->next = c->next;
|
||||||
|
if(c->next)
|
||||||
|
c->next->prev = c->prev;
|
||||||
*l = c->next;
|
*l = c->next;
|
||||||
for(l = &clients; *l; l = &(*l)->next)
|
if(sel == c) {
|
||||||
if((*l)->revert == c)
|
sel = getnext(c->next, tsel);
|
||||||
(*l)->revert = NULL;
|
if(!sel)
|
||||||
if(sel == c)
|
sel = getprev(c->prev);
|
||||||
sel = sel->revert ? sel->revert : clients;
|
if(!sel)
|
||||||
|
sel = clients;
|
||||||
|
}
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -432,7 +476,7 @@ unmanage(Client *c)
|
|||||||
void
|
void
|
||||||
zoom(Arg *arg)
|
zoom(Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c, **l;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
@ -442,6 +486,19 @@ zoom(Arg *arg)
|
|||||||
sel = c;
|
sel = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
pop(sel);
|
/* pop */
|
||||||
|
for(l = &clients; *l && *l != sel; l = &(*l)->next);
|
||||||
|
if(sel->prev)
|
||||||
|
sel->prev->next = sel->next;
|
||||||
|
if(sel->next)
|
||||||
|
sel->next->prev = sel->prev;
|
||||||
|
*l = sel->next;
|
||||||
|
|
||||||
|
sel->prev = NULL;
|
||||||
|
if(clients)
|
||||||
|
clients->prev = sel;
|
||||||
|
sel->next = clients;
|
||||||
|
clients = sel;
|
||||||
|
arrange(NULL);
|
||||||
focus(sel);
|
focus(sel);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ MANPREFIX = ${PREFIX}/share/man
|
|||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
VERSION = 0.4
|
VERSION = 0.5
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
||||||
|
19
draw.c
19
draw.c
@ -14,6 +14,7 @@ static void
|
|||||||
drawborder(void)
|
drawborder(void)
|
||||||
{
|
{
|
||||||
XPoint points[5];
|
XPoint points[5];
|
||||||
|
|
||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
XSetForeground(dpy, dc.gc, dc.border);
|
XSetForeground(dpy, dc.gc, dc.border);
|
||||||
points[0].x = dc.x;
|
points[0].x = dc.x;
|
||||||
@ -33,6 +34,7 @@ static unsigned int
|
|||||||
textnw(char *text, unsigned int len)
|
textnw(char *text, unsigned int len)
|
||||||
{
|
{
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
if(dc.font.set) {
|
if(dc.font.set) {
|
||||||
XmbTextExtents(dc.font.set, text, len, NULL, &r);
|
XmbTextExtents(dc.font.set, text, len, NULL, &r);
|
||||||
return r.width;
|
return r.width;
|
||||||
@ -44,8 +46,8 @@ static void
|
|||||||
drawtext(const char *text, Bool invert, Bool border)
|
drawtext(const char *text, Bool invert, Bool border)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned int len;
|
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
|
unsigned int len;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||||
|
|
||||||
@ -105,7 +107,7 @@ drawall()
|
|||||||
void
|
void
|
||||||
drawstatus()
|
drawstatus()
|
||||||
{
|
{
|
||||||
int i;
|
int i, x;
|
||||||
Bool istile = arrange == dotile;
|
Bool istile = arrange == dotile;
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
@ -121,15 +123,14 @@ drawstatus()
|
|||||||
else
|
else
|
||||||
drawtext(tags[i], (i != tsel), True);
|
drawtext(tags[i], (i != tsel), True);
|
||||||
}
|
}
|
||||||
if(sel) {
|
x = dc.x + dc.w;
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(sel->name);
|
|
||||||
drawtext(sel->name, istile, True);
|
|
||||||
}
|
|
||||||
dc.w = textw(stext);
|
dc.w = textw(stext);
|
||||||
dc.x = bx + bw - dc.w;
|
dc.x = bx + bw - dc.w;
|
||||||
drawtext(stext, !istile, False);
|
drawtext(stext, !istile, False);
|
||||||
|
if(sel && ((dc.w = dc.x - x) >= bh)) {
|
||||||
|
dc.x = x;
|
||||||
|
drawtext(sel->name, istile, True);
|
||||||
|
}
|
||||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
@ -170,8 +171,8 @@ drawtitle(Client *c)
|
|||||||
unsigned long
|
unsigned long
|
||||||
getcolor(const char *colstr)
|
getcolor(const char *colstr)
|
||||||
{
|
{
|
||||||
XColor color;
|
|
||||||
Colormap cmap = DefaultColormap(dpy, screen);
|
Colormap cmap = DefaultColormap(dpy, screen);
|
||||||
|
XColor color;
|
||||||
|
|
||||||
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
|
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
|
||||||
return color.pixel;
|
return color.pixel;
|
||||||
|
17
dwm.1
17
dwm.1
@ -1,4 +1,4 @@
|
|||||||
.TH DWM 1 dwm-0.4
|
.TH DWM 1 dwm-0.5
|
||||||
.SH NAME
|
.SH NAME
|
||||||
dwm \- dynamic window manager
|
dwm \- dynamic window manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -87,25 +87,12 @@ Start
|
|||||||
Lock
|
Lock
|
||||||
.B screen
|
.B screen
|
||||||
.TP
|
.TP
|
||||||
.B Control-[0..n]
|
.B Mod1-Control-[0..n]
|
||||||
Append
|
Append
|
||||||
.B nth
|
.B nth
|
||||||
tag to current
|
tag to current
|
||||||
.B window
|
.B window
|
||||||
.TP
|
.TP
|
||||||
.B Control-Shift-[0..n]
|
|
||||||
Replace current
|
|
||||||
.B window
|
|
||||||
of
|
|
||||||
.B nth
|
|
||||||
tag with current tag.
|
|
||||||
.B window
|
|
||||||
.TP
|
|
||||||
.B Control-Button1
|
|
||||||
Zooms the clicked
|
|
||||||
.B window
|
|
||||||
to master column
|
|
||||||
.TP
|
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
Moves current
|
Moves current
|
||||||
.B window
|
.B window
|
||||||
|
35
dwm.h
35
dwm.h
@ -5,25 +5,25 @@
|
|||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
/* CUSTOMIZE */
|
||||||
|
|
||||||
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
||||||
#define BGCOLOR "#0a2c2d"
|
#define BGCOLOR "#0a2c2d"
|
||||||
#define FGCOLOR "#ddeeee"
|
#define FGCOLOR "#ddeeee"
|
||||||
#define BORDERCOLOR "#176164"
|
#define BORDERCOLOR "#176164"
|
||||||
#define MODKEY Mod1Mask /* Mod4Mask */
|
#define MODKEY Mod1Mask /* Mod4Mask */
|
||||||
/*
|
/*
|
||||||
#define BGCOLOR "#666699"
|
#define BGCOLOR "#666699"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define FGCOLOR "#eeeeee"
|
||||||
#define BORDERCOLOR "#9999CC"
|
#define BORDERCOLOR "#9999CC"
|
||||||
*/
|
*/
|
||||||
#define MASTERW 52 /* percent */
|
#define MASTERW 52 /* percent */
|
||||||
#define WM_PROTOCOL_DELWIN 1
|
#define WM_PROTOCOL_DELWIN 1
|
||||||
|
|
||||||
/* tags */
|
/* tags */
|
||||||
enum { Tscratch, Tdev, Twww, Twork, TLast };
|
enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast };
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
/* END CUSTOMIZE */
|
||||||
|
|
||||||
typedef union Arg Arg;
|
typedef union Arg Arg;
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
@ -74,8 +74,9 @@ struct Client {
|
|||||||
unsigned int border;
|
unsigned int border;
|
||||||
long flags;
|
long flags;
|
||||||
Bool isfloat;
|
Bool isfloat;
|
||||||
|
Bool ismax;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *revert;
|
Client *prev;
|
||||||
Window win;
|
Window win;
|
||||||
Window title;
|
Window title;
|
||||||
};
|
};
|
||||||
@ -104,11 +105,10 @@ extern void higher(Client *c);
|
|||||||
extern void killclient(Arg *arg);
|
extern void killclient(Arg *arg);
|
||||||
extern void lower(Client *c);
|
extern void lower(Client *c);
|
||||||
extern void manage(Window w, XWindowAttributes *wa);
|
extern void manage(Window w, XWindowAttributes *wa);
|
||||||
extern void maximize(Arg *arg);
|
extern void resize(Client *c, Bool sizehints, Corner sticky);
|
||||||
extern void pop(Client *c);
|
|
||||||
extern void resize(Client *c, Bool inc, Corner sticky);
|
|
||||||
extern void setsize(Client *c);
|
extern void setsize(Client *c);
|
||||||
extern void settitle(Client *c);
|
extern void settitle(Client *c);
|
||||||
|
extern void togglemax(Arg *arg);
|
||||||
extern void unmanage(Client *c);
|
extern void unmanage(Client *c);
|
||||||
extern void zoom(Arg *arg);
|
extern void zoom(Arg *arg);
|
||||||
|
|
||||||
@ -134,9 +134,10 @@ extern void appendtag(Arg *arg);
|
|||||||
extern void dofloat(Arg *arg);
|
extern void dofloat(Arg *arg);
|
||||||
extern void dotile(Arg *arg);
|
extern void dotile(Arg *arg);
|
||||||
extern Client *getnext(Client *c, unsigned int t);
|
extern Client *getnext(Client *c, unsigned int t);
|
||||||
extern void heretag(Arg *arg);
|
extern Client *getprev(Client *c);
|
||||||
extern void replacetag(Arg *arg);
|
extern void replacetag(Arg *arg);
|
||||||
extern void settags(Client *c);
|
extern void settags(Client *c);
|
||||||
|
extern void togglemode(Arg *arg);
|
||||||
extern void view(Arg *arg);
|
extern void view(Arg *arg);
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
|
96
event.c
96
event.c
@ -26,60 +26,60 @@ const char *gimp[] = { "gimp", NULL };
|
|||||||
*/
|
*/
|
||||||
const char *term[] = { "xterm", NULL };
|
const char *term[] = { "xterm", NULL };
|
||||||
/*
|
/*
|
||||||
"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
|
"urxvt", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
|
||||||
"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
|
"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
|
||||||
};
|
};
|
||||||
coonst char *xlock[] = { "xlock", NULL };
|
const char *xlock[] = { "xlock", NULL };
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Key key[] = {
|
static Key key[] = {
|
||||||
/* modifier key function arguments */
|
/* modifier key function arguments */
|
||||||
{ ControlMask, XK_0, appendtag, { .i = Tscratch } },
|
{ MODKEY, XK_0, view, { .i = Tfnord } },
|
||||||
{ ControlMask, XK_1, appendtag, { .i = Tdev } },
|
{ MODKEY, XK_1, view, { .i = Tdev } },
|
||||||
{ ControlMask, XK_2, appendtag, { .i = Twww } },
|
{ MODKEY, XK_2, view, { .i = Tnet } },
|
||||||
{ ControlMask, XK_3, appendtag, { .i = Twork } },
|
{ MODKEY, XK_3, view, { .i = Twork } },
|
||||||
{ MODKEY, XK_0, view, { .i = Tscratch } },
|
{ MODKEY, XK_4, view, { .i = Tmisc} },
|
||||||
{ MODKEY, XK_1, view, { .i = Tdev } },
|
{ MODKEY, XK_j, focusnext, { 0 } },
|
||||||
{ MODKEY, XK_2, view, { .i = Twww } },
|
{ MODKEY, XK_k, focusprev, { 0 } },
|
||||||
{ MODKEY, XK_3, view, { .i = Twork } },
|
{ MODKEY, XK_m, togglemax, { 0 } },
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } },
|
{ MODKEY, XK_space, togglemode, { 0 } },
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } },
|
{ MODKEY, XK_Return, zoom, { 0 } },
|
||||||
{ MODKEY, XK_m, maximize, { 0 } },
|
{ MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } },
|
||||||
{ MODKEY, XK_space, dotile, { 0 } },
|
{ MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } },
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } },
|
{ MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } },
|
||||||
{ ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
|
{ MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } },
|
||||||
{ ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
|
{ MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } },
|
||||||
{ ControlMask|ShiftMask,XK_2, heretag, { .i = Twww } },
|
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } },
|
||||||
{ ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } },
|
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } },
|
||||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tscratch } },
|
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } },
|
||||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } },
|
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } },
|
||||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Twww } },
|
{ MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } },
|
||||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } },
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } },
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } },
|
{ MODKEY|ShiftMask, XK_q, quit, { 0 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } },
|
||||||
/*
|
/*
|
||||||
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
|
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
|
||||||
{ MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } },
|
{ MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } },
|
||||||
|
{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },
|
||||||
*/
|
*/
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, dofloat, { 0 } },
|
|
||||||
/*{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },*/
|
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* END CUSTOMIZE */
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
movemouse(Client *c)
|
movemouse(Client *c)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
|
||||||
int x1, y1, ocx, ocy, di;
|
int x1, y1, ocx, ocy, di;
|
||||||
unsigned int dui;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
ocy = c->y;
|
ocy = c->y;
|
||||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
@ -105,9 +105,9 @@ movemouse(Client *c)
|
|||||||
static void
|
static void
|
||||||
resizemouse(Client *c)
|
resizemouse(Client *c)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
|
||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
Corner sticky;
|
Corner sticky;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
ocy = c->y;
|
ocy = c->y;
|
||||||
@ -146,8 +146,8 @@ buttonpress(XEvent *e)
|
|||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
Arg a;
|
Arg a;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
|
||||||
if(barwin == ev->window) {
|
if(barwin == ev->window) {
|
||||||
switch(ev->button) {
|
switch(ev->button) {
|
||||||
@ -176,11 +176,7 @@ buttonpress(XEvent *e)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case Button1:
|
case Button1:
|
||||||
if(arrange == dotile && !c->isfloat) {
|
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||||
if((ev->state & ControlMask) && (ev->button == Button1))
|
|
||||||
zoom(NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
higher(c);
|
higher(c);
|
||||||
movemouse(c);
|
movemouse(c);
|
||||||
}
|
}
|
||||||
@ -189,7 +185,7 @@ buttonpress(XEvent *e)
|
|||||||
lower(c);
|
lower(c);
|
||||||
break;
|
break;
|
||||||
case Button3:
|
case Button3:
|
||||||
if(arrange == dofloat || c->isfloat) {
|
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||||
higher(c);
|
higher(c);
|
||||||
resizemouse(c);
|
resizemouse(c);
|
||||||
}
|
}
|
||||||
@ -201,9 +197,9 @@ buttonpress(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
configurerequest(XEvent *e)
|
configurerequest(XEvent *e)
|
||||||
{
|
{
|
||||||
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
Client *c;
|
|
||||||
|
|
||||||
ev->value_mask &= ~CWSibling;
|
ev->value_mask &= ~CWSibling;
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
@ -248,8 +244,8 @@ destroynotify(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
enternotify(XEvent *e)
|
enternotify(XEvent *e)
|
||||||
{
|
{
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
|
|
||||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||||
return;
|
return;
|
||||||
@ -263,8 +259,8 @@ enternotify(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
expose(XEvent *e)
|
expose(XEvent *e)
|
||||||
{
|
{
|
||||||
XExposeEvent *ev = &e->xexpose;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
XExposeEvent *ev = &e->xexpose;
|
||||||
|
|
||||||
if(ev->count == 0) {
|
if(ev->count == 0) {
|
||||||
if(barwin == ev->window)
|
if(barwin == ev->window)
|
||||||
@ -277,10 +273,10 @@ expose(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
keypress(XEvent *e)
|
keypress(XEvent *e)
|
||||||
{
|
{
|
||||||
XKeyEvent *ev = &e->xkey;
|
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
|
XKeyEvent *ev = &e->xkey;
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
@ -303,8 +299,8 @@ leavenotify(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
maprequest(XEvent *e)
|
maprequest(XEvent *e)
|
||||||
{
|
{
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
|
||||||
static XWindowAttributes wa;
|
static XWindowAttributes wa;
|
||||||
|
XMapRequestEvent *ev = &e->xmaprequest;
|
||||||
|
|
||||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||||
return;
|
return;
|
||||||
@ -322,9 +318,9 @@ maprequest(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
propertynotify(XEvent *e)
|
propertynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
XPropertyEvent *ev = &e->xproperty;
|
|
||||||
Window trans;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
Window trans;
|
||||||
|
XPropertyEvent *ev = &e->xproperty;
|
||||||
|
|
||||||
if(ev->state == PropertyDelete)
|
if(ev->state == PropertyDelete)
|
||||||
return; /* ignore */
|
return; /* ignore */
|
||||||
@ -380,7 +376,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
|||||||
void
|
void
|
||||||
grabkeys()
|
grabkeys()
|
||||||
{
|
{
|
||||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
|
|
||||||
|
88
main.c
88
main.c
@ -10,6 +10,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
@ -17,8 +18,8 @@
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static Bool otherwm;
|
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
|
static Bool otherwm;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup()
|
cleanup()
|
||||||
@ -34,9 +35,8 @@ static void
|
|||||||
scan()
|
scan()
|
||||||
{
|
{
|
||||||
unsigned int i, num;
|
unsigned int i, num;
|
||||||
Window *wins;
|
Window *wins, d1, d2;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
Window d1, d2;
|
|
||||||
|
|
||||||
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||||
for(i = 0; i < num; i++) {
|
for(i = 0; i < num; i++) {
|
||||||
@ -55,10 +55,9 @@ scan()
|
|||||||
static int
|
static int
|
||||||
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
||||||
{
|
{
|
||||||
Atom real;
|
int status, format;
|
||||||
int format;
|
|
||||||
unsigned long res, extra;
|
unsigned long res, extra;
|
||||||
int status;
|
Atom real;
|
||||||
|
|
||||||
status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
|
status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
|
||||||
&res, &extra, prop);
|
&res, &extra, prop);
|
||||||
@ -86,7 +85,9 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
|
|||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
|
/* CUSTOMIZE */
|
||||||
int tsel = Tdev; /* default tag */
|
int tsel = Tdev; /* default tag */
|
||||||
|
/* END CUSTOMIZE */
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
@ -101,10 +102,10 @@ Window root, barwin;
|
|||||||
int
|
int
|
||||||
getproto(Window w)
|
getproto(Window w)
|
||||||
{
|
{
|
||||||
unsigned char *protocols;
|
|
||||||
long res;
|
|
||||||
int protos = 0;
|
int protos = 0;
|
||||||
int i;
|
int i;
|
||||||
|
long res;
|
||||||
|
unsigned char *protocols;
|
||||||
|
|
||||||
res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
|
res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
|
||||||
if(res <= 0) {
|
if(res <= 0) {
|
||||||
@ -148,46 +149,35 @@ int
|
|||||||
xerror(Display *dpy, XErrorEvent *ee)
|
xerror(Display *dpy, XErrorEvent *ee)
|
||||||
{
|
{
|
||||||
if(ee->error_code == BadWindow
|
if(ee->error_code == BadWindow
|
||||||
|| (ee->request_code == X_SetInputFocus
|
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
||||||
&& ee->error_code == BadMatch)
|
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
||||||
|| (ee->request_code == X_PolyText8
|
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
||||||
&& ee->error_code == BadDrawable)
|
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
||||||
|| (ee->request_code == X_PolyFillRectangle
|
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
||||||
&& ee->error_code == BadDrawable)
|
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
|
||||||
|| (ee->request_code == X_PolySegment
|
|
||||||
&& ee->error_code == BadDrawable)
|
|
||||||
|| (ee->request_code == X_ConfigureWindow
|
|
||||||
&& ee->error_code == BadMatch)
|
|
||||||
|| (ee->request_code == X_GrabKey
|
|
||||||
&& ee->error_code == BadAccess))
|
|
||||||
return 0;
|
return 0;
|
||||||
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
||||||
ee->request_code, ee->error_code);
|
ee->request_code, ee->error_code);
|
||||||
return xerrorxlib(dpy, ee); /* may call exit() */
|
return xerrorxlib(dpy, ee); /* may call exit() */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, n;
|
int i;
|
||||||
fd_set rd;
|
|
||||||
XSetWindowAttributes wa;
|
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
Bool readstdin = True;
|
fd_set rd;
|
||||||
|
Bool readin = True;
|
||||||
Window w;
|
Window w;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
|
||||||
for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||||
switch (argv[i][1]) {
|
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||||
default:
|
exit(EXIT_SUCCESS);
|
||||||
eprint("usage: dwm [-v]\n");
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if(argc != 1)
|
||||||
|
eprint("usage: dwm [-v]\n");
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
dpy = XOpenDisplay(0);
|
||||||
if(!dpy)
|
if(!dpy)
|
||||||
@ -254,21 +244,17 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
|
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
|
||||||
| LeaveWindowMask;
|
|
||||||
wa.cursor = cursor[CurNormal];
|
wa.cursor = cursor[CurNormal];
|
||||||
|
|
||||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||||
|
|
||||||
strcpy(stext, "dwm-"VERSION);
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
/* main event loop, reads status text from stdin as well */
|
/* main event loop, reads status text from stdin as well */
|
||||||
Mainloop:
|
|
||||||
while(running) {
|
while(running) {
|
||||||
FD_ZERO(&rd);
|
FD_ZERO(&rd);
|
||||||
if(readstdin)
|
if(readin)
|
||||||
FD_SET(STDIN_FILENO, &rd);
|
FD_SET(STDIN_FILENO, &rd);
|
||||||
FD_SET(ConnectionNumber(dpy), &rd);
|
FD_SET(ConnectionNumber(dpy), &rd);
|
||||||
|
|
||||||
@ -285,20 +271,12 @@ Mainloop:
|
|||||||
(handler[ev.type])(&ev); /* call handler */
|
(handler[ev.type])(&ev); /* call handler */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
|
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
||||||
i = n = 0;
|
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
||||||
for(;;) {
|
if(readin)
|
||||||
if((i = getchar()) == EOF) {
|
stext[strlen(stext) - 1] = 0;
|
||||||
/* broken pipe/end of producer */
|
else
|
||||||
readstdin = False;
|
strcpy(stext, "broken pipe");
|
||||||
strcpy(stext, "broken pipe");
|
|
||||||
goto Mainloop;
|
|
||||||
}
|
|
||||||
if(i == '\n' || n >= sizeof(stext) - 1)
|
|
||||||
break;
|
|
||||||
stext[n++] = i;
|
|
||||||
}
|
|
||||||
stext[n] = 0;
|
|
||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
tag.c
68
tag.c
@ -20,22 +20,25 @@ typedef struct {
|
|||||||
|
|
||||||
/* CUSTOMIZE */
|
/* CUSTOMIZE */
|
||||||
static Rule rule[] = {
|
static Rule rule[] = {
|
||||||
/* class instance tags isfloat */
|
/* class:instance tags isfloat */
|
||||||
{ "Firefox.*", { [Twww] = "www" }, False },
|
{ "Firefox.*", { [Tnet] = "net" }, False },
|
||||||
{ "Gimp.*", { 0 }, True},
|
{ "Gimp.*", { 0 }, True},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char *tags[TLast] = {
|
||||||
|
[Tfnord] = "fnord",
|
||||||
|
[Tdev] = "dev",
|
||||||
|
[Tnet] = "net",
|
||||||
|
[Twork] = "work",
|
||||||
|
[Tmisc] = "misc",
|
||||||
|
};
|
||||||
|
|
||||||
|
void (*arrange)(Arg *) = dotile;
|
||||||
|
|
||||||
|
/* END CUSTOMIZE */
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
/* CUSTOMIZE */
|
|
||||||
char *tags[TLast] = {
|
|
||||||
[Tscratch] = "scratch",
|
|
||||||
[Tdev] = "dev",
|
|
||||||
[Twww] = "www",
|
|
||||||
[Twork] = "work",
|
|
||||||
};
|
|
||||||
void (*arrange)(Arg *) = dotile;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
appendtag(Arg *arg)
|
appendtag(Arg *arg)
|
||||||
{
|
{
|
||||||
@ -51,8 +54,8 @@ dofloat(Arg *arg)
|
|||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
arrange = dofloat;
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
|
c->ismax = False;
|
||||||
if(c->tags[tsel]) {
|
if(c->tags[tsel]) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
}
|
}
|
||||||
@ -71,11 +74,10 @@ dofloat(Arg *arg)
|
|||||||
void
|
void
|
||||||
dotile(Arg *arg)
|
dotile(Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c;
|
|
||||||
int n, i, w, h;
|
int n, i, w, h;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
w = sw - mw;
|
w = sw - mw;
|
||||||
arrange = dotile;
|
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(c->tags[tsel] && !c->isfloat)
|
if(c->tags[tsel] && !c->isfloat)
|
||||||
n++;
|
n++;
|
||||||
@ -86,6 +88,7 @@ dotile(Arg *arg)
|
|||||||
h = sh - bh;
|
h = sh - bh;
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
|
c->ismax = False;
|
||||||
if(c->tags[tsel]) {
|
if(c->tags[tsel]) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
higher(c);
|
higher(c);
|
||||||
@ -138,29 +141,18 @@ getnext(Client *c, unsigned int t)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Client *
|
||||||
heretag(Arg *arg)
|
getprev(Client *c)
|
||||||
{
|
{
|
||||||
int i;
|
for(; c && !c->tags[tsel]; c = c->prev);
|
||||||
Client *c;
|
return c;
|
||||||
|
|
||||||
if(arg->i == tsel)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!(c = getnext(clients, arg->i)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(i = 0; i < TLast; i++)
|
|
||||||
c->tags[i] = NULL;
|
|
||||||
c->tags[tsel] = tags[tsel];
|
|
||||||
pop(c);
|
|
||||||
focus(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
replacetag(Arg *arg)
|
replacetag(Arg *arg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -173,18 +165,13 @@ void
|
|||||||
settags(Client *c)
|
settags(Client *c)
|
||||||
{
|
{
|
||||||
char classinst[256];
|
char classinst[256];
|
||||||
static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
|
static unsigned int len = sizeof(rule) / sizeof(rule[0]);
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
regex_t regex;
|
regex_t regex;
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
Bool matched = False;
|
Bool matched = False;
|
||||||
XClassHint ch;
|
XClassHint ch;
|
||||||
|
|
||||||
if(!len) {
|
|
||||||
c->tags[tsel] = tags[tsel];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
if(XGetClassHint(dpy, c->win, &ch)) {
|
||||||
snprintf(classinst, sizeof(classinst), "%s:%s",
|
snprintf(classinst, sizeof(classinst), "%s:%s",
|
||||||
ch.res_class ? ch.res_class : "",
|
ch.res_class ? ch.res_class : "",
|
||||||
@ -211,6 +198,13 @@ settags(Client *c)
|
|||||||
c->tags[tsel] = tags[tsel];
|
c->tags[tsel] = tags[tsel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglemode(Arg *arg)
|
||||||
|
{
|
||||||
|
arrange = arrange == dofloat ? dotile : dofloat;
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view(Arg *arg)
|
view(Arg *arg)
|
||||||
{
|
{
|
||||||
|
9
util.c
9
util.c
@ -15,9 +15,7 @@
|
|||||||
static void
|
static void
|
||||||
bad_malloc(unsigned int size)
|
bad_malloc(unsigned int size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fatal: could not malloc() %d bytes\n",
|
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||||
(int) size);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
@ -26,6 +24,7 @@ void *
|
|||||||
emallocz(unsigned int size)
|
emallocz(unsigned int size)
|
||||||
{
|
{
|
||||||
void *res = calloc(1, size);
|
void *res = calloc(1, size);
|
||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
bad_malloc(size);
|
bad_malloc(size);
|
||||||
return res;
|
return res;
|
||||||
@ -34,6 +33,7 @@ emallocz(unsigned int size)
|
|||||||
void
|
void
|
||||||
eprint(const char *errstr, ...) {
|
eprint(const char *errstr, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, errstr);
|
va_start(ap, errstr);
|
||||||
vfprintf(stderr, errstr, ap);
|
vfprintf(stderr, errstr, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
@ -44,6 +44,7 @@ void
|
|||||||
spawn(Arg *arg)
|
spawn(Arg *arg)
|
||||||
{
|
{
|
||||||
char **argv = (char **)arg->argv;
|
char **argv = (char **)arg->argv;
|
||||||
|
|
||||||
if(!argv || !argv[0])
|
if(!argv || !argv[0])
|
||||||
return;
|
return;
|
||||||
if(fork() == 0) {
|
if(fork() == 0) {
|
||||||
@ -55,7 +56,7 @@ spawn(Arg *arg)
|
|||||||
fprintf(stderr, "dwm: execvp %s", argv[0]);
|
fprintf(stderr, "dwm: execvp %s", argv[0]);
|
||||||
perror(" failed");
|
perror(" failed");
|
||||||
}
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(0);
|
||||||
}
|
}
|
||||||
wait(0);
|
wait(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user