Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
9ed5de00b6 | |||
28ffff801b | |||
44ef3f5a07 | |||
dafbd0dcb0 | |||
2ddc78720a | |||
7ece30ebc0 | |||
3d48f33025 | |||
19fd903d40 | |||
5732e471ae | |||
042297b27b | |||
a5cb80b86c | |||
7e98db251e | |||
bced9077f9 | |||
82fed986f9 |
2
.hgtags
2
.hgtags
@ -33,3 +33,5 @@ c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
|
||||
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 "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
@echo "LD = ${LD}"
|
||||
|
||||
.c.o:
|
||||
@echo CC $<
|
||||
@ -26,8 +25,8 @@ config.h:
|
||||
@cp config.default.h $@
|
||||
|
||||
dwm: ${OBJ}
|
||||
@echo LD $@
|
||||
@${LD} -o $@ ${OBJ} ${LDFLAGS}
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
@strip $@
|
||||
|
||||
clean:
|
||||
|
70
client.c
70
client.c
@ -7,7 +7,7 @@
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static functions */
|
||||
/* static */
|
||||
|
||||
static void
|
||||
detachstack(Client *c) {
|
||||
@ -53,12 +53,19 @@ grabbuttons(Client *c, Bool focused) {
|
||||
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
|
||||
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* extern functions */
|
||||
/* extern */
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
@ -113,11 +120,26 @@ getclient(Window w) {
|
||||
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
|
||||
killclient(Arg *arg) {
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->proto & PROTODELWIN)
|
||||
if(isprotodel(sel))
|
||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||
else
|
||||
XKillClient(dpy, sel->win);
|
||||
@ -152,7 +174,6 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->y = way;
|
||||
}
|
||||
updatesizehints(c);
|
||||
c->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
@ -169,6 +190,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
stack = clients = c;
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMapWindow(dpy, c->win);
|
||||
setclientstate(c, NormalState);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
arrange();
|
||||
@ -176,15 +198,12 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints) {
|
||||
float actual, dx, dy, max, min;
|
||||
XWindowChanges wc;
|
||||
|
||||
if(c->w <= 0 || c->h <= 0)
|
||||
return;
|
||||
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)
|
||||
c->w = c->minw;
|
||||
if(c->minh && c->h < c->minh)
|
||||
@ -193,6 +212,32 @@ resize(Client *c, Bool sizehints) {
|
||||
c->w = c->maxw;
|
||||
if(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(c->w == sw && c->h == sh)
|
||||
c->border = 0;
|
||||
@ -249,6 +294,14 @@ updatesizehints(Client *c) {
|
||||
}
|
||||
else
|
||||
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->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
@ -293,6 +346,7 @@ unmanage(Client *c) {
|
||||
focus(nc);
|
||||
}
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
setclientstate(c, WithdrawnState);
|
||||
free(c->tags);
|
||||
free(c);
|
||||
XSync(dpy, False);
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 3.2.2
|
||||
VERSION = 3.4
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -27,4 +27,3 @@ LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
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;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
XPoint pt[5];
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
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);
|
||||
}
|
||||
x = (h + 2) / 4;
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
if(filledsquare) {
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
r.width = r.height = x + 1;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
else if(emptysquare) {
|
||||
pt[0].x = dc.x + 1;
|
||||
pt[0].y = dc.y + 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);
|
||||
r.width = r.height = x;
|
||||
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
6
dwm.1
6
dwm.1
@ -131,7 +131,9 @@ Resize current window while dragging (floating mode only).
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH CAVEATS
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
.SH BUGS
|
||||
The status bar may display
|
||||
.BR "EOF"
|
||||
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
|
||||
backend instead):
|
||||
.BR AWT_TOOLKIT=MToolkit .
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
|
10
dwm.h
10
dwm.h
@ -36,11 +36,9 @@
|
||||
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
/* other stuff used in different places */
|
||||
#define PROTODELWIN 1
|
||||
|
||||
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 { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
@ -69,13 +67,13 @@ typedef struct {
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
char name[256];
|
||||
int proto;
|
||||
int x, y, w, h;
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int minax, minay, maxax, maxay;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
Bool isfixed, isfloat, ismax;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
Client *prev;
|
||||
@ -104,6 +102,7 @@ extern Window root, barwin;
|
||||
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 Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
|
||||
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); /* resize c*/
|
||||
@ -122,7 +121,6 @@ extern void grabkeys(void); /* grab all keys defined in config.h */
|
||||
extern void procevent(void); /* process pending X events */
|
||||
|
||||
/* 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 sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
||||
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
4
event.c
4
event.c
@ -308,10 +308,6 @@ propertynotify(XEvent *e) {
|
||||
if(ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
if((c = getclient(ev->window))) {
|
||||
if(ev->atom == wmatom[WMProtocols]) {
|
||||
c->proto = getproto(c->win);
|
||||
return;
|
||||
}
|
||||
switch (ev->atom) {
|
||||
default: break;
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
|
19
main.c
19
main.c
@ -92,6 +92,7 @@ setup(void) {
|
||||
/* init atoms */
|
||||
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||
@ -171,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||
|
||||
/* 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
|
||||
sendevent(Window w, Atom a, long value) {
|
||||
XEvent e;
|
||||
|
10
view.c
10
view.c
@ -98,11 +98,11 @@ dotile(void) {
|
||||
else { /* tile window */
|
||||
c->x += mw;
|
||||
c->w = tw - 2 * BORDERPX;
|
||||
if(th - 2 * BORDERPX > bh) {
|
||||
if(th > 2 * BORDERPX) {
|
||||
c->y += (i - nmaster) * th;
|
||||
c->h = th - 2 * BORDERPX;
|
||||
}
|
||||
else /* fallback if th - 2 * BORDERPX < bh */
|
||||
else /* fallback if th <= 2 * BORDERPX */
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, False);
|
||||
@ -150,7 +150,7 @@ focusprev(Arg *arg) {
|
||||
void
|
||||
incnmaster(Arg *arg) {
|
||||
if((arrange == dofloat) || (nmaster + arg->i < 1)
|
||||
|| (wah / (nmaster + arg->i) - 2 * BORDERPX < bh))
|
||||
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
||||
return;
|
||||
nmaster += arg->i;
|
||||
if(sel)
|
||||
@ -174,8 +174,8 @@ resizemaster(Arg *arg) {
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(waw * (master + arg->i) / 1000 > waw - bh - 2 * BORDERPX
|
||||
|| waw * (master + arg->i) / 1000 < bh + 2 * BORDERPX)
|
||||
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
|
||||
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
|
Reference in New Issue
Block a user