Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
9ed5de00b6 | |||
28ffff801b | |||
44ef3f5a07 | |||
dafbd0dcb0 | |||
2ddc78720a | |||
7ece30ebc0 | |||
3d48f33025 | |||
19fd903d40 | |||
5732e471ae | |||
042297b27b | |||
a5cb80b86c | |||
7e98db251e | |||
bced9077f9 | |||
82fed986f9 | |||
2c1db7ed35 | |||
ea4827a578 | |||
55be4d6137 | |||
1f18466409 | |||
b65a1e3379 | |||
87836d79ef | |||
c8a12a0852 | |||
71b84c2114 | |||
edb2660a2e | |||
17ec726b49 | |||
373b11de11 | |||
04a2b74529 | |||
fcd98308ba | |||
b233089815 | |||
201c56f6d3 | |||
1e051d71f5 | |||
ddc79603f9 | |||
dee5ea2335 | |||
b1c9f5f144 | |||
a542bdf658 | |||
96e1b25c8c | |||
caf5a16271 | |||
936e11fd54 |
5
.hgtags
5
.hgtags
@ -30,3 +30,8 @@ c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
|
|||||||
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
|
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
|
||||||
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
|
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
|
||||||
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0
|
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0
|
||||||
|
e1c8bef05e6e48df4f26471ea0712aa43ab9d949 3.1
|
||||||
|
4ce65f61f01b055fa6c2901c6d2527ef741aa4bf 3.2
|
||||||
|
f2cabc83a18f9b5b548159329ddd4dee904fa31f 3.2.1
|
||||||
|
d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||||
|
0f91934037b04221ff5d1ba3a6c39c1ff26e3661 3.3
|
||||||
|
5
Makefile
5
Makefile
@ -13,7 +13,6 @@ options:
|
|||||||
@echo "CFLAGS = ${CFLAGS}"
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
@echo "LDFLAGS = ${LDFLAGS}"
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
@echo "CC = ${CC}"
|
@echo "CC = ${CC}"
|
||||||
@echo "LD = ${LD}"
|
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo CC $<
|
@echo CC $<
|
||||||
@ -26,8 +25,8 @@ config.h:
|
|||||||
@cp config.default.h $@
|
@cp config.default.h $@
|
||||||
|
|
||||||
dwm: ${OBJ}
|
dwm: ${OBJ}
|
||||||
@echo LD $@
|
@echo CC -o $@
|
||||||
@${LD} -o $@ ${OBJ} ${LDFLAGS}
|
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
@strip $@
|
@strip $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
150
client.c
150
client.c
@ -7,7 +7,7 @@
|
|||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
/* static functions */
|
/* static */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
detachstack(Client *c) {
|
detachstack(Client *c) {
|
||||||
@ -53,12 +53,19 @@ grabbuttons(Client *c, Bool focused) {
|
|||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setclientstate(Client *c, long state) {
|
||||||
|
long data[] = {state, None};
|
||||||
|
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
|
||||||
|
PropModeReplace, (unsigned char *)data, 2);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extern functions */
|
/* extern */
|
||||||
|
|
||||||
void
|
void
|
||||||
configure(Client *c) {
|
configure(Client *c) {
|
||||||
@ -79,31 +86,28 @@ configure(Client *c) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
focus(Client *c) {
|
focus(Client *c) {
|
||||||
Client *old;
|
if(c && !isvisible(c))
|
||||||
|
|
||||||
if(!issel || (c && !isvisible(c)))
|
|
||||||
return;
|
return;
|
||||||
if(!sel)
|
if(sel && sel != c) {
|
||||||
sel = c;
|
grabbuttons(sel, False);
|
||||||
else if(sel != c) {
|
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
|
||||||
old = sel;
|
|
||||||
sel = c;
|
|
||||||
if(old) {
|
|
||||||
grabbuttons(old, False);
|
|
||||||
XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(c) {
|
if(c) {
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
c->snext = stack;
|
c->snext = stack;
|
||||||
stack = c;
|
stack = c;
|
||||||
grabbuttons(c, True);
|
grabbuttons(c, True);
|
||||||
|
}
|
||||||
|
sel = c;
|
||||||
|
drawstatus();
|
||||||
|
if(!selscreen)
|
||||||
|
return;
|
||||||
|
if(c) {
|
||||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
|
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
drawstatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
@ -116,11 +120,26 @@ getclient(Window w) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
isprotodel(Client *c) {
|
||||||
|
int i, n;
|
||||||
|
Atom *protocols;
|
||||||
|
Bool ret = False;
|
||||||
|
|
||||||
|
if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
|
||||||
|
for(i = 0; !ret && i < n; i++)
|
||||||
|
if(protocols[i] == wmatom[WMDelete])
|
||||||
|
ret = True;
|
||||||
|
XFree(protocols);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
killclient(Arg *arg) {
|
killclient(Arg *arg) {
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
if(sel->proto & PROTODELWIN)
|
if(isprotodel(sel))
|
||||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||||
else
|
else
|
||||||
XKillClient(dpy, sel->win);
|
XKillClient(dpy, sel->win);
|
||||||
@ -134,25 +153,32 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
c = emallocz(sizeof(Client));
|
c = emallocz(sizeof(Client));
|
||||||
c->tags = emallocz(ntags * sizeof(Bool));
|
c->tags = emallocz(ntags * sizeof(Bool));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
c->border = 0;
|
|
||||||
c->x = wa->x;
|
c->x = wa->x;
|
||||||
c->y = wa->y;
|
c->y = wa->y;
|
||||||
c->w = wa->width;
|
c->w = wa->width;
|
||||||
c->h = wa->height;
|
c->h = wa->height;
|
||||||
updatesizehints(c);
|
if(c->w == sw && c->h == sh) {
|
||||||
if(c->x + c->w + 2 * BORDERPX > sw)
|
c->border = 0;
|
||||||
c->x = sw - c->w - 2 * BORDERPX;
|
|
||||||
if(c->x < sx)
|
|
||||||
c->x = sx;
|
c->x = sx;
|
||||||
if(c->y + c->h + 2 * BORDERPX > sh)
|
c->y = sy;
|
||||||
c->y = sh - c->h - 2 * BORDERPX;
|
}
|
||||||
if(c->h != sh && c->y < bh)
|
else {
|
||||||
c->y = bh;
|
c->border = BORDERPX;
|
||||||
c->proto = getproto(c->win);
|
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);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
grabbuttons(c, False);
|
grabbuttons(c, False);
|
||||||
|
XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
settags(c, getclient(trans));
|
settags(c, getclient(trans));
|
||||||
if(!c->isfloat)
|
if(!c->isfloat)
|
||||||
@ -164,22 +190,20 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
stack = clients = c;
|
stack = clients = c;
|
||||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
|
setclientstate(c, NormalState);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange();
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resize(Client *c, Bool sizehints, Corner sticky) {
|
resize(Client *c, Bool sizehints) {
|
||||||
int bottom = c->y + c->h;
|
float actual, dx, dy, max, min;
|
||||||
int right = c->x + c->w;
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
|
if(c->w <= 0 || c->h <= 0)
|
||||||
|
return;
|
||||||
if(sizehints) {
|
if(sizehints) {
|
||||||
if(c->incw)
|
|
||||||
c->w -= (c->w - c->basew) % c->incw;
|
|
||||||
if(c->inch)
|
|
||||||
c->h -= (c->h - c->baseh) % c->inch;
|
|
||||||
if(c->minw && c->w < c->minw)
|
if(c->minw && c->w < c->minw)
|
||||||
c->w = c->minw;
|
c->w = c->minw;
|
||||||
if(c->minh && c->h < c->minh)
|
if(c->minh && c->h < c->minh)
|
||||||
@ -188,28 +212,51 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
|||||||
c->w = c->maxw;
|
c->w = c->maxw;
|
||||||
if(c->maxh && c->h > c->maxh)
|
if(c->maxh && c->h > c->maxh)
|
||||||
c->h = c->maxh;
|
c->h = c->maxh;
|
||||||
|
/* inspired by algorithm from fluxbox */
|
||||||
|
if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
|
||||||
|
dx = (float)(c->w - c->basew);
|
||||||
|
dy = (float)(c->h - c->baseh);
|
||||||
|
min = (float)(c->minax) / (float)(c->minay);
|
||||||
|
max = (float)(c->maxax) / (float)(c->maxay);
|
||||||
|
actual = dx / dy;
|
||||||
|
if(max > 0 && min > 0 && actual > 0) {
|
||||||
|
if(actual < min) {
|
||||||
|
dy = (dx * min + dy) / (min * min + 1);
|
||||||
|
dx = dy * min;
|
||||||
|
c->w = (int)dx + c->basew;
|
||||||
|
c->h = (int)dy + c->baseh;
|
||||||
|
}
|
||||||
|
else if(actual > max) {
|
||||||
|
dy = (dx * min + dy) / (max * max + 1);
|
||||||
|
dx = dy * min;
|
||||||
|
c->w = (int)dx + c->basew;
|
||||||
|
c->h = (int)dy + c->baseh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(c->incw)
|
||||||
|
c->w -= (c->w - c->basew) % c->incw;
|
||||||
|
if(c->inch)
|
||||||
|
c->h -= (c->h - c->baseh) % c->inch;
|
||||||
}
|
}
|
||||||
if(sticky == TopRight || sticky == BotRight)
|
if(c->w == sw && c->h == sh)
|
||||||
c->x = right - c->w;
|
c->border = 0;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
else
|
||||||
c->y = bottom - c->h;
|
c->border = BORDERPX;
|
||||||
/* offscreen appearance fixes */
|
/* 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)
|
if(c->x > sw)
|
||||||
c->x = sw - c->w;
|
c->x = sw - c->w - 2 * c->border;
|
||||||
if(c->y > sh)
|
if(c->y > sh)
|
||||||
c->y = sh - c->h;
|
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.x = c->x;
|
||||||
wc.y = c->y;
|
wc.y = c->y;
|
||||||
wc.width = c->w;
|
wc.width = c->w;
|
||||||
wc.height = c->h;
|
wc.height = c->h;
|
||||||
if(c->w == sw && c->h == sh)
|
wc.border_width = c->border;
|
||||||
wc.border_width = 0;
|
|
||||||
else
|
|
||||||
wc.border_width = BORDERPX;
|
|
||||||
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -247,6 +294,14 @@ updatesizehints(Client *c) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->minw = c->minh = 0;
|
c->minw = c->minh = 0;
|
||||||
|
if(c->flags & PAspect) {
|
||||||
|
c->minax = size.min_aspect.x;
|
||||||
|
c->minay = size.min_aspect.y;
|
||||||
|
c->maxax = size.max_aspect.x;
|
||||||
|
c->maxay = size.max_aspect.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c->minax = c->minay = c->maxax = c->maxay = 0;
|
||||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
c->maxw == c->minw && c->maxh == c->minh);
|
||||||
}
|
}
|
||||||
@ -291,6 +346,7 @@ unmanage(Client *c) {
|
|||||||
focus(nc);
|
focus(nc);
|
||||||
}
|
}
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
|
setclientstate(c, WithdrawnState);
|
||||||
free(c->tags);
|
free(c->tags);
|
||||||
free(c);
|
free(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||||
|
|
||||||
|
#define BORDERPX 1
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "><>"
|
#define FLOATSYMBOL "><>"
|
||||||
#define TILESYMBOL "[]="
|
#define TILESYMBOL "[]="
|
||||||
@ -13,7 +14,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
|||||||
#define NORMBORDERCOLOR "#333"
|
#define NORMBORDERCOLOR "#333"
|
||||||
#define NORMBGCOLOR "#222"
|
#define NORMBGCOLOR "#222"
|
||||||
#define NORMFGCOLOR "#ccc"
|
#define NORMFGCOLOR "#ccc"
|
||||||
#define SELBORDERCOLOR "#9cf"
|
#define SELBORDERCOLOR "#69c"
|
||||||
#define SELBGCOLOR "#555"
|
#define SELBGCOLOR "#555"
|
||||||
#define SELFGCOLOR "#fff"
|
#define SELFGCOLOR "#fff"
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||||
|
|
||||||
|
#define BORDERPX 1
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "><>"
|
#define FLOATSYMBOL "><>"
|
||||||
#define TILESYMBOL "[]="
|
#define TILESYMBOL "[]="
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 3.1
|
VERSION = 3.4
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
@ -27,4 +27,3 @@ LDFLAGS = ${LIBS}
|
|||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
CC = cc
|
CC = cc
|
||||||
LD = ${CC}
|
|
||||||
|
18
draw.c
18
draw.c
@ -35,7 +35,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
|
|||||||
unsigned int len, olen;
|
unsigned int len, olen;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||||
XPoint pt[5];
|
|
||||||
|
|
||||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
@ -74,24 +73,15 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
|
|||||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||||
}
|
}
|
||||||
x = (h + 2) / 4;
|
x = (h + 2) / 4;
|
||||||
|
r.x = dc.x + 1;
|
||||||
|
r.y = dc.y + 1;
|
||||||
if(filledsquare) {
|
if(filledsquare) {
|
||||||
r.x = dc.x + 1;
|
|
||||||
r.y = dc.y + 1;
|
|
||||||
r.width = r.height = x + 1;
|
r.width = r.height = x + 1;
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
}
|
}
|
||||||
else if(emptysquare) {
|
else if(emptysquare) {
|
||||||
pt[0].x = dc.x + 1;
|
r.width = r.height = x;
|
||||||
pt[0].y = dc.y + 1;
|
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
pt[1].x = x;
|
|
||||||
pt[1].y = 0;
|
|
||||||
pt[2].x = 0;
|
|
||||||
pt[2].y = x;
|
|
||||||
pt[3].x = -x;
|
|
||||||
pt[3].y = 0;
|
|
||||||
pt[4].x = 0;
|
|
||||||
pt[4].y = -x;
|
|
||||||
XDrawLines(dpy, dc.drawable, dc.gc, pt, 5, CoordModePrevious);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
dwm.1
8
dwm.1
@ -25,7 +25,7 @@ window are indicated with a filled square in the top left corner. The tags
|
|||||||
which are applied to one or more windows 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.
|
the top left corner.
|
||||||
.P
|
.P
|
||||||
dwm draws a 1-pixel border around windows to indicate the focus state.
|
dwm draws a small border around windows to indicate the focus state.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
@ -131,7 +131,9 @@ Resize current window while dragging (floating mode only).
|
|||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
.SH CAVEATS
|
.SH SEE ALSO
|
||||||
|
.BR dmenu (1)
|
||||||
|
.SH BUGS
|
||||||
The status bar may display
|
The status bar may display
|
||||||
.BR "EOF"
|
.BR "EOF"
|
||||||
when dwm has been started by an X session manager like
|
when dwm has been started by an X session manager like
|
||||||
@ -145,5 +147,3 @@ 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
|
can set the following environment variable (to use the older Motif
|
||||||
backend instead):
|
backend instead):
|
||||||
.BR AWT_TOOLKIT=MToolkit .
|
.BR AWT_TOOLKIT=MToolkit .
|
||||||
.SH SEE ALSO
|
|
||||||
.BR dmenu (1)
|
|
||||||
|
19
dwm.h
19
dwm.h
@ -36,19 +36,12 @@
|
|||||||
|
|
||||||
/* mask shorthands, used in event.c and client.c */
|
/* mask shorthands, used in event.c and client.c */
|
||||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||||
/* other stuff used in different places */
|
|
||||||
#define BORDERPX 1
|
|
||||||
#define PROTODELWIN 1
|
|
||||||
|
|
||||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||||
enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TopLeft, TopRight, BotLeft, BotRight
|
|
||||||
} Corner; /* window corners */
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
int i;
|
int i;
|
||||||
@ -74,13 +67,13 @@ typedef struct {
|
|||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
char name[256];
|
char name[256];
|
||||||
int proto;
|
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
int rx, ry, rw, rh; /* revert geometry */
|
int rx, ry, rw, rh; /* revert geometry */
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
|
int minax, minay, maxax, maxay;
|
||||||
long flags;
|
long flags;
|
||||||
unsigned int border;
|
unsigned int border;
|
||||||
Bool isfloat, isfixed, ismax;
|
Bool isfixed, isfloat, ismax;
|
||||||
Bool *tags;
|
Bool *tags;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *prev;
|
Client *prev;
|
||||||
@ -98,7 +91,7 @@ extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
|||||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||||
extern void (*arrange)(void); /* arrange function, indicates mode */
|
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
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 Client *clients, *sel, *stack; /* global client list and stack */
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc; /* global draw context */
|
extern DC dc; /* global draw context */
|
||||||
@ -109,9 +102,10 @@ extern Window root, barwin;
|
|||||||
extern void configure(Client *c); /* send synthetic configure event */
|
extern void configure(Client *c); /* send synthetic configure event */
|
||||||
extern void focus(Client *c); /* focus c, c may be NULL */
|
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||||
extern Client *getclient(Window w); /* return client of w */
|
extern Client *getclient(Window w); /* return client of w */
|
||||||
|
extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
|
||||||
extern void killclient(Arg *arg); /* kill c nicely */
|
extern void killclient(Arg *arg); /* kill c nicely */
|
||||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||||
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
|
extern void resize(Client *c, Bool sizehints); /* resize c*/
|
||||||
extern void updatesizehints(Client *c); /* update the size hint variables of 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 updatetitle(Client *c); /* update the name of c */
|
||||||
extern void unmanage(Client *c); /* destroy c */
|
extern void unmanage(Client *c); /* destroy c */
|
||||||
@ -127,7 +121,6 @@ extern void grabkeys(void); /* grab all keys defined in config.h */
|
|||||||
extern void procevent(void); /* process pending X events */
|
extern void procevent(void); /* process pending X events */
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
|
|
||||||
extern void quit(Arg *arg); /* quit dwm nicely */
|
extern void quit(Arg *arg); /* quit dwm nicely */
|
||||||
extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
||||||
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||||
|
62
event.c
62
event.c
@ -35,14 +35,16 @@ movemouse(Client *c) {
|
|||||||
c->ismax = False;
|
c->ismax = False;
|
||||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
resize(c, True, TopLeft);
|
resize(c, True);
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
return;
|
return;
|
||||||
|
case ConfigureRequest:
|
||||||
case Expose:
|
case Expose:
|
||||||
handler[Expose](&ev);
|
case MapRequest:
|
||||||
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -50,13 +52,13 @@ movemouse(Client *c) {
|
|||||||
c->y = ocy + (ev.xmotion.y - y1);
|
c->y = ocy + (ev.xmotion.y - y1);
|
||||||
if(abs(wax + c->x) < SNAP)
|
if(abs(wax + c->x) < SNAP)
|
||||||
c->x = wax;
|
c->x = wax;
|
||||||
else if(abs((wax + waw) - (c->x + c->w)) < SNAP)
|
else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
|
||||||
c->x = wax + waw - c->w - 2 * BORDERPX;
|
c->x = wax + waw - c->w - 2 * c->border;
|
||||||
if(abs(way - c->y) < SNAP)
|
if(abs(way - c->y) < SNAP)
|
||||||
c->y = way;
|
c->y = way;
|
||||||
else if(abs((way + wah) - (c->y + c->h)) < SNAP)
|
else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
|
||||||
c->y = way + wah - c->h - 2 * BORDERPX;
|
c->y = way + wah - c->h - 2 * c->border;
|
||||||
resize(c, False, TopLeft);
|
resize(c, False);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +68,6 @@ static void
|
|||||||
resizemouse(Client *c) {
|
resizemouse(Client *c) {
|
||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
int nw, nh;
|
int nw, nh;
|
||||||
Corner sticky;
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
@ -75,30 +76,26 @@ resizemouse(Client *c) {
|
|||||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
c->ismax = False;
|
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(;;) {
|
for(;;) {
|
||||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
resize(c, True, TopLeft);
|
resize(c, True);
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
return;
|
return;
|
||||||
|
case ConfigureRequest:
|
||||||
case Expose:
|
case Expose:
|
||||||
handler[Expose](&ev);
|
case MapRequest:
|
||||||
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
if((nw = abs(ocx - ev.xmotion.x)))
|
nw = ev.xmotion.x - ocx - 2 * c->border + 1;
|
||||||
c->w = nw;
|
c->w = nw > 0 ? nw : 1;
|
||||||
if((nh = abs(ocy - ev.xmotion.y)))
|
nh = ev.xmotion.y - ocy - 2 * c->border + 1;
|
||||||
c->h = nh;
|
c->h = nh > 0 ? nh : 1;
|
||||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
resize(c, True);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +191,7 @@ configurerequest(XEvent *e) {
|
|||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
resize(c, False, TopLeft);
|
resize(c, False);
|
||||||
if(!isvisible(c))
|
if(!isvisible(c))
|
||||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
}
|
}
|
||||||
@ -233,8 +230,9 @@ enternotify(XEvent *e) {
|
|||||||
if((c = getclient(ev->window)) && isvisible(c))
|
if((c = getclient(ev->window)) && isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
else if(ev->window == root) {
|
else if(ev->window == root) {
|
||||||
issel = True;
|
selscreen = True;
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
|
focus(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,8 +268,10 @@ static void
|
|||||||
leavenotify(XEvent *e) {
|
leavenotify(XEvent *e) {
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
|
|
||||||
if((ev->window == root) && !ev->same_screen)
|
if((ev->window == root) && !ev->same_screen) {
|
||||||
issel = False;
|
selscreen = False;
|
||||||
|
focus(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -308,10 +308,6 @@ propertynotify(XEvent *e) {
|
|||||||
if(ev->state == PropertyDelete)
|
if(ev->state == PropertyDelete)
|
||||||
return; /* ignore */
|
return; /* ignore */
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
if(ev->atom == wmatom[WMProtocols]) {
|
|
||||||
c->proto = getproto(c->win);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (ev->atom) {
|
switch (ev->atom) {
|
||||||
default: break;
|
default: break;
|
||||||
case XA_WM_TRANSIENT_FOR:
|
case XA_WM_TRANSIENT_FOR:
|
||||||
|
25
main.c
25
main.c
@ -23,7 +23,7 @@ int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
|||||||
unsigned int master, nmaster, ntags, numlockmask;
|
unsigned int master, nmaster, ntags, numlockmask;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Bool issel = True;
|
Bool selscreen = True;
|
||||||
Client *clients = NULL;
|
Client *clients = NULL;
|
||||||
Client *sel = NULL;
|
Client *sel = NULL;
|
||||||
Client *stack = NULL;
|
Client *stack = NULL;
|
||||||
@ -41,7 +41,7 @@ static void
|
|||||||
cleanup(void) {
|
cleanup(void) {
|
||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
while(stack) {
|
while(stack) {
|
||||||
resize(stack, True, TopLeft);
|
resize(stack, True);
|
||||||
unmanage(stack);
|
unmanage(stack);
|
||||||
}
|
}
|
||||||
if(dc.font.set)
|
if(dc.font.set)
|
||||||
@ -92,6 +92,7 @@ setup(void) {
|
|||||||
/* init atoms */
|
/* init atoms */
|
||||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||||
|
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||||
@ -156,7 +157,7 @@ setup(void) {
|
|||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
/* multihead support */
|
/* multihead support */
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -171,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
|||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
int
|
|
||||||
getproto(Window w) {
|
|
||||||
int i, format, protos, status;
|
|
||||||
unsigned long extra, res;
|
|
||||||
Atom *protocols, real;
|
|
||||||
|
|
||||||
protos = 0;
|
|
||||||
status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
|
|
||||||
XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
|
|
||||||
if(status != Success || protocols == 0)
|
|
||||||
return protos;
|
|
||||||
for(i = 0; i < res; i++)
|
|
||||||
if(protocols[i] == wmatom[WMDelete])
|
|
||||||
protos |= PROTODELWIN;
|
|
||||||
free(protocols);
|
|
||||||
return protos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sendevent(Window w, Atom a, long value) {
|
sendevent(Window w, Atom a, long value) {
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
18
view.c
18
view.c
@ -31,7 +31,7 @@ togglemax(Client *c) {
|
|||||||
c->w = c->rw;
|
c->w = c->rw;
|
||||||
c->h = c->rh;
|
c->h = c->rh;
|
||||||
}
|
}
|
||||||
resize(c, True, TopLeft);
|
resize(c, True);
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ dofloat(void) {
|
|||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
@ -84,7 +84,7 @@ dotile(void) {
|
|||||||
for(i = 0, c = clients; c; c = c->next)
|
for(i = 0, c = clients; c; c = c->next)
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c->ismax = False;
|
c->ismax = False;
|
||||||
@ -98,14 +98,14 @@ dotile(void) {
|
|||||||
else { /* tile window */
|
else { /* tile window */
|
||||||
c->x += mw;
|
c->x += mw;
|
||||||
c->w = tw - 2 * BORDERPX;
|
c->w = tw - 2 * BORDERPX;
|
||||||
if(th > bh) {
|
if(th > 2 * BORDERPX) {
|
||||||
c->y += (i - nmaster) * th;
|
c->y += (i - nmaster) * th;
|
||||||
c->h = th - 2 * BORDERPX;
|
c->h = th - 2 * BORDERPX;
|
||||||
}
|
}
|
||||||
else /* fallback if th < bh */
|
else /* fallback if th <= 2 * BORDERPX */
|
||||||
c->h = wah - 2 * BORDERPX;
|
c->h = wah - 2 * BORDERPX;
|
||||||
}
|
}
|
||||||
resize(c, False, TopLeft);
|
resize(c, False);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -149,7 +149,8 @@ focusprev(Arg *arg) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(Arg *arg) {
|
incnmaster(Arg *arg) {
|
||||||
if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
|
if((arrange == dofloat) || (nmaster + arg->i < 1)
|
||||||
|
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
||||||
return;
|
return;
|
||||||
nmaster += arg->i;
|
nmaster += arg->i;
|
||||||
if(sel)
|
if(sel)
|
||||||
@ -173,7 +174,8 @@ resizemaster(Arg *arg) {
|
|||||||
if(arg->i == 0)
|
if(arg->i == 0)
|
||||||
master = MASTER;
|
master = MASTER;
|
||||||
else {
|
else {
|
||||||
if(master + arg->i > 950 || master + arg->i < 50)
|
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
|
||||||
|
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
|
||||||
return;
|
return;
|
||||||
master += arg->i;
|
master += arg->i;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user