Compare commits
278 Commits
Author | SHA1 | Date | |
---|---|---|---|
93aeaa53c9 | |||
06f9f346e6 | |||
5c48012ad2 | |||
a686c9ccd2 | |||
9ca5c3b108 | |||
bab5b1178d | |||
ee8fb0c6e4 | |||
0d9d3e79e9 | |||
12280f0253 | |||
a58731e835 | |||
1df45593ed | |||
2122e39ce1 | |||
e70139428a | |||
3d1d75a224 | |||
35f08f4231 | |||
0ea0343a63 | |||
338c083858 | |||
671442e89d | |||
8d111632f5 | |||
fe5acb939a | |||
cac492b0e9 | |||
ef9b3e173c | |||
5a13632afb | |||
587100873a | |||
27b0595af7 | |||
12d5a26fd2 | |||
89b7f1503e | |||
5711609203 | |||
825b7c3eb1 | |||
ba96131af0 | |||
2c477cf661 | |||
986ca73074 | |||
288098893c | |||
cb9607c284 | |||
4bd4f421d3 | |||
84432e6b36 | |||
1a25414ace | |||
3171371498 | |||
92105e7862 | |||
6ee9f13457 | |||
352cae4380 | |||
b3b58c08e4 | |||
204f0a340d | |||
78666b99b8 | |||
0bdcf75e25 | |||
f1009285d8 | |||
f76b3a4685 | |||
84ae6e12eb | |||
784659565a | |||
7ae0c198b3 | |||
dc6623728d | |||
7541f1ad49 | |||
74cbbe5f35 | |||
52f0b9e2e3 | |||
29c26b88e7 | |||
f196b71e4d | |||
ab83872134 | |||
ad4962c7eb | |||
d180ba418c | |||
138b7fbd05 | |||
e7508783e8 | |||
f4d15b1fec | |||
355beb53f0 | |||
8012fcf333 | |||
6bc4556ebd | |||
879241c05c | |||
3794c62945 | |||
5a03daf47f | |||
6d5f67a092 | |||
cee56d3863 | |||
7c4da24465 | |||
cdbc84b9a8 | |||
b2f895166a | |||
ebe68f650a | |||
df9fd28f9a | |||
e9c49ddd7a | |||
f8415019d4 | |||
238dd5d2b1 | |||
64871a7045 | |||
2e95bc0413 | |||
4cdbd523e5 | |||
b3d7e07f18 | |||
30af19d442 | |||
5d9146ff37 | |||
5cc27f1b3c | |||
39ed54a468 | |||
b61f91361c | |||
3167373512 | |||
4cff744438 | |||
c3527bea57 | |||
de6695792a | |||
6e22ccf7b1 | |||
8a5f002c41 | |||
3ce8c9f338 | |||
0d095ae2ff | |||
2d7f59424c | |||
e256afe31e | |||
64cfebc5e7 | |||
7a095d0ce2 | |||
5052c538d9 | |||
22d8c6fd18 | |||
71857b87ee | |||
6ba400ee0f | |||
35e65ea640 | |||
d0d986dd0e | |||
9685e7dbc2 | |||
37f39afb8e | |||
dc9f62f393 | |||
7055315725 | |||
fd995dac78 | |||
e5765cdd84 | |||
8d0e58f80b | |||
8fcd1bfda8 | |||
e39e697998 | |||
d2dd58eabd | |||
c6fc6b173d | |||
4590d7877c | |||
f577fe4e27 | |||
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 | |||
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 | |||
7009ebfa69 | |||
760e23dd3a | |||
c53d9d516a | |||
7739e6b466 | |||
4881857458 | |||
c73d5cb7b6 | |||
6458803d21 | |||
6e72d781f7 | |||
4e926a9ef2 | |||
4ba3cfaee9 | |||
e655e8a7d5 | |||
c34e4e4b39 | |||
a678ee6365 | |||
49f0ee329d | |||
0c9d9a3d94 | |||
89e1acb0bb | |||
c2ed26b711 | |||
42fd392e05 | |||
e06447ee88 | |||
683dabe5e6 | |||
3aff96177c | |||
0a915eba8f | |||
19dcbc5717 | |||
d2a4952956 | |||
0c97b21b61 | |||
19390b1a91 | |||
8dc86051df | |||
46d5f9d1bf | |||
35e96b8deb | |||
2210ea7e3b | |||
61a1910f91 | |||
27ef73507b | |||
2b35fb643e | |||
478f6f95f1 | |||
44411d2d48 | |||
a2175cf71a |
20
.hgtags
20
.hgtags
@ -21,3 +21,23 @@ a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||
12deea36603da407e3f32640048846a3bd74a9ec 2.0
|
||||
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
|
||||
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
|
||||
d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
0f91934037b04221ff5d1ba3a6c39c1ff26e3661 3.3
|
||||
9ede7b2d2450537e750d5505789fbe63960e97e6 3.4
|
||||
63ad05e7f9e1f4f1881fb02f529cb6c6ae81e693 3.5
|
||||
75b1b25fe0d7e29400baf30568153f668324928b 3.6
|
||||
20ec6976cee1fcfee0c2f354ae382ee3f9f68efa 3.6.1
|
||||
baee494346e520f8dee2cee9491b8350064770d2 3.7
|
||||
2ea201354cf016407ea93e1e390d1422940d29b0 3.8
|
||||
|
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"),
|
||||
|
11
Makefile
11
Makefile
@ -1,9 +1,9 @@
|
||||
# dwm - dynamic window manager
|
||||
# (C)opyright MMVI Anselm R. Garbe
|
||||
# (C)opyright MMVI-MMVII Anselm R. Garbe
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = client.c draw.c event.c main.c tag.c util.c view.c
|
||||
SRC = client.c draw.c event.c layout.c main.c tag.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: options dwm
|
||||
@ -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:
|
||||
@ -50,7 +49,7 @@ install: all
|
||||
@chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
||||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||
@sed 's/VERSION/${VERSION}/g' < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
@sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
|
||||
uninstall:
|
||||
|
413
client.c
413
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"
|
||||
@ -7,11 +7,18 @@
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static functions */
|
||||
/* static */
|
||||
|
||||
static void
|
||||
attachstack(Client *c) {
|
||||
c->snext = stack;
|
||||
stack = c;
|
||||
}
|
||||
|
||||
static void
|
||||
detachstack(Client *c) {
|
||||
Client **tc;
|
||||
|
||||
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
|
||||
*tc = c->snext;
|
||||
}
|
||||
@ -53,262 +60,250 @@ grabbuttons(Client *c, Bool focused) {
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
}
|
||||
|
||||
static 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;
|
||||
}
|
||||
|
||||
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
|
||||
ban(Client *c) {
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
||||
attach(Client *c) {
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
clients = c;
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
XEvent synev;
|
||||
XConfigureEvent ce;
|
||||
|
||||
synev.type = ConfigureNotify;
|
||||
synev.xconfigure.display = dpy;
|
||||
synev.xconfigure.event = c->win;
|
||||
synev.xconfigure.window = c->win;
|
||||
synev.xconfigure.x = c->x;
|
||||
synev.xconfigure.y = c->y;
|
||||
synev.xconfigure.width = c->w;
|
||||
synev.xconfigure.height = c->h;
|
||||
synev.xconfigure.border_width = c->border;
|
||||
synev.xconfigure.above = None;
|
||||
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
||||
ce.type = ConfigureNotify;
|
||||
ce.display = dpy;
|
||||
ce.event = c->win;
|
||||
ce.window = c->win;
|
||||
ce.x = c->x;
|
||||
ce.y = c->y;
|
||||
ce.width = c->w;
|
||||
ce.height = c->h;
|
||||
ce.border_width = c->border;
|
||||
ce.above = None;
|
||||
ce.override_redirect = False;
|
||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
}
|
||||
|
||||
void
|
||||
detach(Client *c) {
|
||||
if(c->prev)
|
||||
c->prev->next = c->next;
|
||||
if(c->next)
|
||||
c->next->prev = c->prev;
|
||||
if(c == clients)
|
||||
clients = c->next;
|
||||
c->next = c->prev = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
attachstack(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
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
|
||||
Client *
|
||||
getclient(Window w) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->win == w)
|
||||
return c;
|
||||
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;
|
||||
killclient(const char *arg) {
|
||||
XEvent ev;
|
||||
|
||||
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)
|
||||
return;
|
||||
if(sel->proto & PROTODELWIN)
|
||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||
if(isprotodel(sel)) {
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = sel->win;
|
||||
ev.xclient.message_type = wmatom[WMProtocols];
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = wmatom[WMDelete];
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
|
||||
}
|
||||
else
|
||||
XKillClient(dpy, sel->win);
|
||||
}
|
||||
|
||||
void
|
||||
manage(Window w, XWindowAttributes *wa) {
|
||||
Client *c;
|
||||
Client *c, *t;
|
||||
Window trans;
|
||||
XSetWindowAttributes twa;
|
||||
XWindowChanges wc;
|
||||
|
||||
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->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
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);
|
||||
XSelectInput(dpy, w,
|
||||
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);
|
||||
XGetTransientForHint(dpy, w, &trans);
|
||||
grabbuttons(c, False);
|
||||
wc.border_width = c->border;
|
||||
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
|
||||
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
|
||||
configure(c); /* propagates border_width, if size doesn't change */
|
||||
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);
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapWindow(dpy, c->twin);
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
settags(c, t);
|
||||
if(!c->isfloating)
|
||||
c->isfloating = (t != NULL) || c->isfixed;
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
c->isbanned = True;
|
||||
XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
|
||||
XMapWindow(dpy, w);
|
||||
setclientstate(c, NormalState);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
arrange();
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
int bottom = c->y + c->h;
|
||||
int right = c->x + c->w;
|
||||
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
float dx, dy, max, min, ratio;
|
||||
XWindowChanges wc;
|
||||
|
||||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
if(sizehints) {
|
||||
if(c->minay > 0 && c->maxay > 0 && (h - c->baseh) > 0) {
|
||||
dx = (float)(w - c->basew);
|
||||
dy = (float)(h - c->baseh);
|
||||
min = (float)(c->minax) / (float)(c->minay);
|
||||
max = (float)(c->maxax) / (float)(c->maxay);
|
||||
ratio = dx / dy;
|
||||
if(max > 0 && min > 0 && ratio > 0) {
|
||||
if(ratio < min) {
|
||||
dy = (dx * min + dy) / (min * min + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
else if(ratio > max) {
|
||||
dy = (dx * min + dy) / (max * max + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c->minw && w < c->minw)
|
||||
w = c->minw;
|
||||
if(c->minh && h < c->minh)
|
||||
h = c->minh;
|
||||
if(c->maxw && w > c->maxw)
|
||||
w = c->maxw;
|
||||
if(c->maxh && h > c->maxh)
|
||||
h = c->maxh;
|
||||
if(c->incw)
|
||||
c->w -= (c->w - c->basew) % c->incw;
|
||||
w -= (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)
|
||||
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;
|
||||
h -= (h - c->baseh) % c->inch;
|
||||
}
|
||||
if(sticky == TopRight || sticky == BotRight)
|
||||
c->x = right - c->w;
|
||||
if(sticky == BotLeft || sticky == BotRight)
|
||||
c->y = bottom - c->h;
|
||||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
if(w == sw && 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;
|
||||
if(c->y > sh)
|
||||
c->y = sh - c->h;
|
||||
resizetitle(c);
|
||||
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;
|
||||
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(x > sw)
|
||||
x = sw - w - 2 * c->border;
|
||||
if(y > sh)
|
||||
y = sh - h - 2 * c->border;
|
||||
if(x + w + 2 * c->border < sx)
|
||||
x = sx;
|
||||
if(y + h + 2 * c->border < sy)
|
||||
y = sy;
|
||||
if(c->x != x || c->y != y || c->w != w || c->h != h) {
|
||||
c->x = wc.x = x;
|
||||
c->y = wc.y = y;
|
||||
c->w = wc.width = w;
|
||||
c->h = wc.height = h;
|
||||
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);
|
||||
togglefloating(const char *arg) {
|
||||
if(!sel || lt->arrange == floating)
|
||||
return;
|
||||
sel->isfloating = !sel->isfloating;
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
updatesize(Client *c) {
|
||||
updatesizehints(Client *c) {
|
||||
long msize;
|
||||
XSizeHints size;
|
||||
|
||||
@ -319,6 +314,10 @@ updatesize(Client *c) {
|
||||
c->basew = size.base_width;
|
||||
c->baseh = size.base_height;
|
||||
}
|
||||
else if(c->flags & PMinSize) {
|
||||
c->basew = size.min_width;
|
||||
c->baseh = size.min_height;
|
||||
}
|
||||
else
|
||||
c->basew = c->baseh = 0;
|
||||
if(c->flags & PResizeInc) {
|
||||
@ -337,14 +336,22 @@ updatesize(Client *c) {
|
||||
c->minw = size.min_width;
|
||||
c->minh = size.min_height;
|
||||
}
|
||||
else if(c->flags & PBaseSize) {
|
||||
c->minw = size.base_width;
|
||||
c->minh = size.base_height;
|
||||
}
|
||||
else
|
||||
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;
|
||||
if(c->flags & PAspect) {
|
||||
c->minax = size.min_aspect.x;
|
||||
c->maxax = size.max_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxay = size.max_aspect.y;
|
||||
}
|
||||
else
|
||||
c->grav = NorthWestGravity;
|
||||
c->minax = c->maxax = c->minay = c->maxay = 0;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
|
||||
&& c->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
|
||||
void
|
||||
@ -361,12 +368,12 @@ updatetitle(Client *c) {
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||
else {
|
||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
strncpy(c->name, *list, sizeof(c->name));
|
||||
strncpy(c->name, *list, sizeof c->name);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
}
|
||||
@ -387,11 +394,11 @@ unmanage(Client *c) {
|
||||
focus(nc);
|
||||
}
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
XDestroyWindow(dpy, c->twin);
|
||||
setclientstate(c, WithdrawnState);
|
||||
free(c->tags);
|
||||
free(c);
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
arrange();
|
||||
lt->arrange();
|
||||
}
|
||||
|
152
config.arg.h
152
config.arg.h
@ -1,67 +1,99 @@
|
||||
/* (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.
|
||||
*/
|
||||
|
||||
/* appearance */
|
||||
#define BORDERPX 1
|
||||
#define FONT "-*-proggyclean-medium-r-*-*-13-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#333"
|
||||
#define NORMBGCOLOR "#222"
|
||||
#define NORMFGCOLOR "#ccc"
|
||||
#define SELBORDERCOLOR "#8c8"
|
||||
#define SELBGCOLOR "#555"
|
||||
#define SELFGCOLOR "#fff"
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*"
|
||||
#define NORMBGCOLOR "#333333"
|
||||
#define NORMFGCOLOR "#dddddd"
|
||||
#define SELBGCOLOR "#336699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define STATUSBGCOLOR "#222222"
|
||||
#define STATUSFGCOLOR "#99ccff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define SNAP 40 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||
{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +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" } }, \
|
||||
{ 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|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "net", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
{ "MPlayer.*", NULL, True }, \
|
||||
{ "Acroread.*", NULL, True }, \
|
||||
/* class:instance:title regex tags regex isfloating */ \
|
||||
{ "Firefox", "3", False }, \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
{ "Acroread", NULL, True }, \
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
#define LAYOUTS \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define MASTERWIDTH 600 /* master width per thousand */
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 32 /* snap pixel */
|
||||
|
||||
/* key definitions */
|
||||
#define MODKEY Mod1Mask
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function argument */ \
|
||||
{ MODKEY, XK_p, spawn, \
|
||||
"exe=`dmenu_path | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"'" \
|
||||
" -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'` && exec $exe" }, \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||
"exec urxvtcd -tr -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_h, incmasterw, "-32" }, \
|
||||
{ MODKEY, XK_l, incmasterw, "32" }, \
|
||||
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
|
||||
{ MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
|
||||
{ MODKEY, XK_j, focusclient, "1" }, \
|
||||
{ MODKEY, XK_k, focusclient, "-1" }, \
|
||||
{ MODKEY, XK_m, togglemax, NULL }, \
|
||||
{ MODKEY, XK_Return, zoom, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, NULL }, \
|
||||
{ MODKEY, XK_0, view, NULL }, \
|
||||
{ MODKEY, XK_1, view, "0" }, \
|
||||
{ MODKEY, XK_2, view, "1" }, \
|
||||
{ MODKEY, XK_3, view, "2" }, \
|
||||
{ MODKEY, XK_4, view, "3" }, \
|
||||
{ MODKEY, XK_5, view, "4" }, \
|
||||
{ MODKEY, XK_6, view, "5" }, \
|
||||
{ MODKEY, XK_7, view, "6" }, \
|
||||
{ MODKEY, XK_8, view, "7" }, \
|
||||
{ MODKEY, XK_9, view, "8" }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, "0" }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, "1" }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, "2" }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, "3" }, \
|
||||
{ MODKEY|ControlMask, XK_5, toggleview, "4" }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, "5" }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, "6" }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, "7" }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, "8" }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_1, tag, "0" }, \
|
||||
{ MODKEY|ShiftMask, XK_2, tag, "1" }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, "2" }, \
|
||||
{ MODKEY|ShiftMask, XK_4, tag, "3" }, \
|
||||
{ MODKEY|ShiftMask, XK_5, tag, "4" }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, "5" }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, "6" }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, "7" }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, "8" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, NULL }, \
|
||||
};
|
||||
|
145
config.default.h
145
config.default.h
@ -1,66 +1,97 @@
|
||||
/* (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.
|
||||
*/
|
||||
|
||||
/* appearance */
|
||||
#define BORDERPX 1
|
||||
#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 TOPBAR True /* False */
|
||||
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||
|
||||
#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 MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define SNAP 20 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
||||
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ 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|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|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||
{ 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|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
/* Query class:instance:title for regex matching info with following command:
|
||||
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "2", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
/* class:instance:title regex tags regex isfloating */ \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
{ "Acroread", NULL, True }, \
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
#define LAYOUTS \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define MASTERWIDTH 600 /* master width per thousand */
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 32 /* snap pixel */
|
||||
|
||||
/* key definitions */
|
||||
#define MODKEY Mod1Mask
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function argument */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, "exec xterm" }, \
|
||||
{ MODKEY, XK_p, spawn, "exe=`dmenu_path | dmenu` && exec $exe" }, \
|
||||
{ MODKEY, XK_space, setlayout, NULL }, \
|
||||
{ MODKEY, XK_h, incmasterw, "-32" }, \
|
||||
{ MODKEY, XK_l, incmasterw, "32" }, \
|
||||
{ MODKEY|ShiftMask, XK_j, incnmaster, "1" }, \
|
||||
{ MODKEY|ShiftMask, XK_k, incnmaster, "-1" }, \
|
||||
{ MODKEY, XK_j, focusclient, "1" }, \
|
||||
{ MODKEY, XK_k, focusclient, "-1" }, \
|
||||
{ MODKEY, XK_m, togglemax, NULL }, \
|
||||
{ MODKEY, XK_Return, zoom, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, NULL }, \
|
||||
{ MODKEY, XK_0, view, NULL }, \
|
||||
{ MODKEY, XK_1, view, "0" }, \
|
||||
{ MODKEY, XK_2, view, "1" }, \
|
||||
{ MODKEY, XK_3, view, "2" }, \
|
||||
{ MODKEY, XK_4, view, "3" }, \
|
||||
{ MODKEY, XK_5, view, "4" }, \
|
||||
{ MODKEY, XK_6, view, "5" }, \
|
||||
{ MODKEY, XK_7, view, "6" }, \
|
||||
{ MODKEY, XK_8, view, "7" }, \
|
||||
{ MODKEY, XK_9, view, "8" }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, "0" }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, "1" }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, "2" }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, "3" }, \
|
||||
{ MODKEY|ControlMask, XK_5, toggleview, "4" }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, "5" }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, "6" }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, "7" }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, "8" }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, NULL }, \
|
||||
{ MODKEY|ShiftMask, XK_1, tag, "0" }, \
|
||||
{ MODKEY|ShiftMask, XK_2, tag, "1" }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, "2" }, \
|
||||
{ MODKEY|ShiftMask, XK_4, tag, "3" }, \
|
||||
{ MODKEY|ShiftMask, XK_5, tag, "4" }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, "5" }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, "6" }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, "7" }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, "8" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, "0" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, "1" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, "2" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, "3" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, "4" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, "5" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, "6" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, "7" }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, "8" }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, NULL }, \
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 2.3
|
||||
VERSION = 3.9
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -20,6 +20,10 @@ 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}
|
||||
|
223
draw.c
223
draw.c
@ -1,17 +1,36 @@
|
||||
/* (C)opyright MMIV-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>
|
||||
#include <string.h>
|
||||
#include <X11/Xlocale.h>
|
||||
|
||||
/* static */
|
||||
|
||||
static void
|
||||
drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
|
||||
int x;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
|
||||
gcv.foreground = col[ColFG];
|
||||
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||
x = (dc.font.ascent + dc.font.descent + 2) / 4;
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
if(filled) {
|
||||
r.width = r.height = x + 1;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
else if(empty) {
|
||||
r.width = r.height = x;
|
||||
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static Bool
|
||||
isoccupied(unsigned int t)
|
||||
{
|
||||
isoccupied(unsigned int t) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tags[t])
|
||||
return True;
|
||||
@ -29,12 +48,53 @@ textnw(const char *text, unsigned int len) {
|
||||
return XTextWidth(dc.font.xfont, text, len);
|
||||
}
|
||||
|
||||
static void
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
|
||||
/* extern */
|
||||
|
||||
void
|
||||
drawstatus(void) {
|
||||
int i, x;
|
||||
|
||||
dc.x = dc.y = 0;
|
||||
for(i = 0; i < ntags; i++) {
|
||||
dc.w = textw(tags[i]);
|
||||
if(seltag[i]) {
|
||||
drawtext(tags[i], dc.sel);
|
||||
drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel);
|
||||
}
|
||||
else {
|
||||
drawtext(tags[i], dc.norm);
|
||||
drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm);
|
||||
}
|
||||
dc.x += dc.w;
|
||||
}
|
||||
dc.w = blw;
|
||||
drawtext(lt->symbol, dc.norm);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = sw - dc.w;
|
||||
if(dc.x < x) {
|
||||
dc.x = x;
|
||||
dc.w = sw - x;
|
||||
}
|
||||
drawtext(stext, dc.norm);
|
||||
if((dc.w = dc.x - x) > bh) {
|
||||
dc.x = x;
|
||||
if(sel) {
|
||||
drawtext(sel->name, dc.sel);
|
||||
drawsquare(sel->ismax, sel->isfloating, dc.sel);
|
||||
}
|
||||
else
|
||||
drawtext(NULL, dc.norm);
|
||||
}
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
@ -43,8 +103,8 @@ drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
|
||||
return;
|
||||
w = 0;
|
||||
olen = len = strlen(text);
|
||||
if(len >= sizeof(buf))
|
||||
len = sizeof(buf) - 1;
|
||||
if(len >= sizeof buf)
|
||||
len = sizeof buf - 1;
|
||||
memcpy(buf, text, len);
|
||||
buf[len] = 0;
|
||||
h = dc.font.ascent + dc.font.descent;
|
||||
@ -63,146 +123,11 @@ drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
|
||||
}
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = col[ColFG];
|
||||
if(dc.font.set) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||
}
|
||||
else {
|
||||
gcv.font = dc.font.xfont->fid;
|
||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
if(ldot) {
|
||||
r.x = dc.x + 2;
|
||||
r.y = dc.y + 2;
|
||||
r.width = r.height = (h + 2) / 4;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
if(rdot) {
|
||||
r.width = r.height = (h + 2) / 4;
|
||||
r.x = dc.x + dc.w - r.width - 2;
|
||||
r.y = dc.y + dc.h - r.height - 2;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
drawall(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = getnext(c->next))
|
||||
drawtitle(c);
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
drawstatus(void) {
|
||||
int i, x;
|
||||
|
||||
dc.x = dc.y = 0;
|
||||
for(i = 0; i < ntags; i++) {
|
||||
dc.w = textw(tags[i]);
|
||||
if(seltag[i])
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i));
|
||||
else
|
||||
drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i));
|
||||
dc.x += dc.w;
|
||||
}
|
||||
dc.w = bmw;
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False, False);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bw - dc.w;
|
||||
if(dc.x < x) {
|
||||
dc.x = x;
|
||||
dc.w = bw - x;
|
||||
}
|
||||
drawtext(stext, dc.status, 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);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
getcolor(const char *colstr) {
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
XColor color;
|
||||
|
||||
if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
|
||||
eprint("error, cannot allocate color '%s'\n", colstr);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
void
|
||||
setfont(const char *fontstr) {
|
||||
char **missing, *def;
|
||||
int i, n;
|
||||
|
||||
missing = NULL;
|
||||
setlocale(LC_ALL, "");
|
||||
XSetForeground(dpy, dc.gc, col[ColFG]);
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
if(missing) {
|
||||
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;
|
||||
XFontStruct **xfonts;
|
||||
char **font_names;
|
||||
dc.font.ascent = dc.font.descent = 0;
|
||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||
for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
|
||||
if(dc.font.ascent < (*xfonts)->ascent)
|
||||
dc.font.ascent = (*xfonts)->ascent;
|
||||
if(dc.font.descent < (*xfonts)->descent)
|
||||
dc.font.descent = (*xfonts)->descent;
|
||||
xfonts++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
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");
|
||||
dc.font.ascent = dc.font.xfont->ascent;
|
||||
dc.font.descent = dc.font.xfont->descent;
|
||||
}
|
||||
dc.font.height = dc.font.ascent + dc.font.descent;
|
||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||
else
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
|
124
dwm.1
124
dwm.1
@ -1,32 +1,33 @@
|
||||
.TH DWM 1 dwm-VERSION
|
||||
.TH DWM 1 dwm\-VERSION
|
||||
.SH NAME
|
||||
dwm \- dynamic window manager
|
||||
.SH SYNOPSIS
|
||||
.B dwm
|
||||
.RB [ \-v ]
|
||||
.SH DESCRIPTION
|
||||
dwm is a dynamic window manager for X. It manages windows in tiling and
|
||||
floating modes. Either mode can be applied dynamically, optimizing the
|
||||
dwm is a dynamic window manager for X. It manages windows in tiled and
|
||||
floating layouts. Either layout 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
|
||||
stacking area contains all other windows. In floating mode windows can be
|
||||
In tiled layout windows are managed in a master and stacking area. The master
|
||||
area contains the windows which currently need most attention, whereas the
|
||||
stacking area contains all other windows. In floating layout windows can be
|
||||
resized and moved freely. Dialog windows are always managed floating,
|
||||
regardless of the mode selected.
|
||||
regardless of the layout 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.
|
||||
.P
|
||||
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 small point in the top left corner. The tags which
|
||||
are applied by any client are indicated with a small point in the bottom
|
||||
right corner.
|
||||
dwm contains a small status bar which displays all available tags, the layout,
|
||||
the title of the focused window, and the text read from standard input. A
|
||||
floating window is indicated with an empty square and a maximized
|
||||
floating window is indicated with a filled square before the windows
|
||||
title. 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 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
|
||||
@ -38,87 +39,110 @@ prints version information to standard output, then exits.
|
||||
is read and displayed in the status text area.
|
||||
.TP
|
||||
.B Button1
|
||||
click on a tag label to display all windows with that tag, click on the mode
|
||||
label toggles between tiling and floating mode.
|
||||
click on a tag label to display all windows with that tag, click on the layout
|
||||
label toggles between tiled and floating layout.
|
||||
.TP
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
.B Mod1\-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
.B Mod1\-Button3
|
||||
click on a tag label adds/removes that tag to/from the focused window.
|
||||
.SS Keyboard commands
|
||||
.TP
|
||||
.B Mod1-Shift-Return
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR xterm (1).
|
||||
.BR xterm.
|
||||
.TP
|
||||
.B Mod1-Tab
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1-Shift-Tab
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1-Return
|
||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
||||
.B Mod1\-Shift\-j
|
||||
Increase the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-g
|
||||
Grow master area (tiling mode only).
|
||||
.B Mod1\-Shift\-k
|
||||
Decrease the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-s
|
||||
Shrink master area (tiling mode only).
|
||||
.B Mod1\-l
|
||||
Increase master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-Shift-[1..n]
|
||||
.B Mod1\-h
|
||||
Decrease master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-m
|
||||
Toggles maximization of current window (floating layout only).
|
||||
.TP
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply
|
||||
.RB nth
|
||||
tag to current window.
|
||||
.TP
|
||||
.B Mod1-Control-Shift-[1..n]
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to current window.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-[1..n]
|
||||
Add/remove
|
||||
.B nth
|
||||
tag to/from current window.
|
||||
.TP
|
||||
.B Mod1-Shift-c
|
||||
.B Mod1\-Shift\-c
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1-space
|
||||
Toggle between tiling and floating mode (affects all windows).
|
||||
.B Mod1\-space
|
||||
Toggle between tiled and floating layout (affects all windows).
|
||||
.TP
|
||||
.B Mod1-[1..n]
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state (tiled layout only).
|
||||
.TP
|
||||
.B Mod1\-[1..n]
|
||||
View all windows with
|
||||
.BR nth
|
||||
tag.
|
||||
.TP
|
||||
.B Mod1-0
|
||||
.B Mod1\-0
|
||||
View all windows with any tag.
|
||||
.TP
|
||||
.B Mod1-Control-[1..n]
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with
|
||||
.BR nth
|
||||
tag to/from the view.
|
||||
.TP
|
||||
.B Mod1-Shift-q
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
Move current window while dragging (floating mode only).
|
||||
.B Mod1\-Button1
|
||||
Move current window while dragging (floating layout only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
Zoom current window to the master area (tiling mode only).
|
||||
.B Mod1\-Button2
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
Resize current window while dragging (floating mode only).
|
||||
.B Mod1\-Button3
|
||||
Resize current window while dragging (floating layout 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
|
||||
The status bar may display
|
||||
.BR "broken pipe"
|
||||
when dwm has been started by
|
||||
.BR xdm (1),
|
||||
because it closes standard output before executing dwm.
|
||||
.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
|
||||
.BR xdm (1),
|
||||
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 .
|
||||
|
188
dwm.h
188
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
|
||||
@ -24,9 +24,8 @@
|
||||
*
|
||||
* Keys and tagging rules are organized as arrays and defined in the config.h
|
||||
* file. These arrays are kept static in event.o and tag.o respectively,
|
||||
* because no other part of dwm needs access to them. The current mode is
|
||||
* represented by the arrange() function pointer, which wether points to
|
||||
* dofloat() or dotile().
|
||||
* because no other part of dwm needs access to them. The current layout is
|
||||
* represented by the lt pointer.
|
||||
*
|
||||
* To understand everything else, start reading main.c:main().
|
||||
*/
|
||||
@ -36,136 +35,113 @@
|
||||
|
||||
/* 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 { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef enum {
|
||||
TopLeft, TopRight, BotLeft, BotRight
|
||||
} Corner; /* window corners */
|
||||
|
||||
typedef union {
|
||||
const char *cmd;
|
||||
int i;
|
||||
} Arg; /* argument type */
|
||||
|
||||
typedef struct {
|
||||
int ascent;
|
||||
int descent;
|
||||
int height;
|
||||
XFontSet set;
|
||||
XFontStruct *xfont;
|
||||
} Fnt;
|
||||
|
||||
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;
|
||||
} DC; /* draw context */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
char name[256];
|
||||
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;
|
||||
int minax, maxax, minay, maxay;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
Bool isbanned, isfixed, ismax, isfloating;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
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 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 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 Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc; /* global draw context */
|
||||
extern Display *dpy;
|
||||
extern Window root, barwin;
|
||||
typedef struct {
|
||||
int x, y, w, h;
|
||||
unsigned long norm[ColLast];
|
||||
unsigned long sel[ColLast];
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
struct {
|
||||
int ascent;
|
||||
int descent;
|
||||
int height;
|
||||
XFontSet set;
|
||||
XFontStruct *xfont;
|
||||
} font;
|
||||
} DC; /* draw context */
|
||||
|
||||
typedef struct {
|
||||
const char *symbol;
|
||||
void (*arrange)(void);
|
||||
} Layout;
|
||||
|
||||
extern const char *tags[]; /* all tags */
|
||||
char stext[256]; /* status text */
|
||||
int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
int wax, way, wah, waw; /* windowarea geometry */
|
||||
unsigned int bh, blw; /* bar height, bar layout label width */
|
||||
unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
||||
void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool selscreen, *seltag; /* seltag is array of Bool */
|
||||
Client *clients, *sel, *stack; /* global client list and stack */
|
||||
Cursor cursor[CurLast];
|
||||
DC dc; /* global draw context */
|
||||
Display *dpy;
|
||||
Layout *lt;
|
||||
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 updatetitle(Client *c); /* update the name of c */
|
||||
extern void unmanage(Client *c); /* destroy c */
|
||||
void attach(Client *c); /* attaches c to global client list */
|
||||
void configure(Client *c); /* send synthetic configure event */
|
||||
void detach(Client *c); /* detaches c from global client list */
|
||||
void focus(Client *c); /* focus c, c may be NULL */
|
||||
void killclient(const char *arg); /* kill c nicely */
|
||||
void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
void resize(Client *c, int x, int y,
|
||||
int w, int h, Bool sizehints); /* resize with given coordinates c*/
|
||||
void togglefloating(const char *arg); /* toggles focused client between floating/tiled state */
|
||||
void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
void updatetitle(Client *c); /* update the name of c */
|
||||
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*/
|
||||
void drawstatus(void); /* draw the bar */
|
||||
void drawtext(const char *text, unsigned long col[ColLast]); /* draw text */
|
||||
unsigned int textw(const char *text); /* return the width of text in px*/
|
||||
|
||||
/* event.c */
|
||||
extern void grabkeys(void); /* grab all keys defined in config.h */
|
||||
extern void procevent(void); /* process pending X events */
|
||||
void grabkeys(void); /* grab all keys defined in config.h */
|
||||
|
||||
/* layout.c */
|
||||
void floating(void); /* arranges all windows floating */
|
||||
void focusclient(const char *arg); /* focuses next(1)/previous(-1) visible client */
|
||||
void incmasterw(const char *arg); /* increments the master width with arg's index value */
|
||||
void incnmaster(const char *arg); /* increments nmaster with arg's index value */
|
||||
void initlayouts(void); /* initialize layout array */
|
||||
Client *nexttiled(Client *c); /* returns tiled successor of c */
|
||||
void restack(void); /* restores z layers of all clients */
|
||||
void setlayout(const char *arg); /* sets layout, -1 toggles */
|
||||
void togglemax(const char *arg); /* toggles maximization of floating client */
|
||||
void zoom(const char *arg); /* zooms the focused client to master area, arg is ignored */
|
||||
|
||||
/* 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 */
|
||||
void quit(const char *arg); /* quit dwm nicely */
|
||||
int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
||||
/* tag.c */
|
||||
extern void initrregs(void); /* initialize regexps of rules defined in config.h */
|
||||
extern Client *getnext(Client *c); /* returns next visible client */
|
||||
extern Client *getprev(Client *c); /* returns previous visible client */
|
||||
extern void settags(Client *c, Client *trans); /* sets tags of c */
|
||||
extern void tag(Arg *arg); /* tags c with arg's index */
|
||||
extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
|
||||
void compileregs(void); /* initialize regexps of rules defined in config.h */
|
||||
Bool isvisible(Client *c); /* returns True if client is visible */
|
||||
void settags(Client *c, Client *trans); /* sets tags of c */
|
||||
void tag(const char *arg); /* tags c with arg's index */
|
||||
void toggletag(const char *arg); /* toggles c tags with arg's index */
|
||||
void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
|
||||
void view(const char *arg); /* views the tag 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 */
|
||||
extern void detach(Client *c); /* detaches c from global client list */
|
||||
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 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 */
|
||||
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
|
||||
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
|
||||
extern void view(Arg *arg); /* views the tag with arg's index */
|
||||
extern void viewall(Arg *arg); /* views all tags, arg is ignored */
|
||||
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
|
||||
void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
|
||||
void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||
void spawn(const char *arg); /* forks a new subprocess with arg's cmd */
|
||||
|
212
event.c
212
event.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>
|
||||
#include <stdlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
@ -11,8 +12,8 @@
|
||||
typedef struct {
|
||||
unsigned long mod;
|
||||
KeySym keysym;
|
||||
void (*func)(Arg *arg);
|
||||
Arg arg;
|
||||
void (*func)(const char *arg);
|
||||
const char *arg;
|
||||
} Key;
|
||||
|
||||
KEYS
|
||||
@ -20,43 +21,52 @@ KEYS
|
||||
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||
|
||||
static Client *
|
||||
getclient(Window w) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c && c->win != w; c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
movemouse(Client *c) {
|
||||
int x1, y1, ocx, ocy, di;
|
||||
int x1, y1, ocx, ocy, di, nx, ny;
|
||||
unsigned int dui;
|
||||
Window dummy;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
ocx = nx = c->x;
|
||||
ocy = ny = c->y;
|
||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
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);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
c->x = ocx + (ev.xmotion.x - x1);
|
||||
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;
|
||||
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);
|
||||
nx = ocx + (ev.xmotion.x - x1);
|
||||
ny = ocy + (ev.xmotion.y - y1);
|
||||
if(abs(wax + nx) < SNAP)
|
||||
nx = wax;
|
||||
else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
|
||||
nx = wax + waw - c->w - 2 * c->border;
|
||||
if(abs(way - ny) < SNAP)
|
||||
ny = way;
|
||||
else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
|
||||
ny = way + wah - c->h - 2 * c->border;
|
||||
resize(c, nx, ny, c->w, c->h, False);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -66,7 +76,6 @@ static void
|
||||
resizemouse(Client *c) {
|
||||
int ocx, ocy;
|
||||
int nw, nh;
|
||||
Corner sticky;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
@ -75,30 +84,28 @@ 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);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
|
||||
c->w + c->border - 1, c->h + c->border - 1);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
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);
|
||||
if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
||||
nw = 1;
|
||||
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
||||
nh = 1;
|
||||
resize(c, c->x, c->y, nw, nh, True);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -106,46 +113,53 @@ resizemouse(Client *c) {
|
||||
|
||||
static void
|
||||
buttonpress(XEvent *e) {
|
||||
int x;
|
||||
Arg a;
|
||||
static char buf[32];
|
||||
unsigned int i, x;
|
||||
Client *c;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
buf[0] = 0;
|
||||
if(barwin == ev->window) {
|
||||
x = 0;
|
||||
for(a.i = 0; a.i < ntags; a.i++) {
|
||||
x += textw(tags[a.i]);
|
||||
for(i = 0; i < ntags; i++) {
|
||||
x += textw(tags[i]);
|
||||
if(ev->x < x) {
|
||||
snprintf(buf, sizeof buf, "%d", i);
|
||||
if(ev->button == Button1) {
|
||||
if(ev->state & MODKEY)
|
||||
tag(&a);
|
||||
tag(buf);
|
||||
else
|
||||
view(&a);
|
||||
view(buf);
|
||||
}
|
||||
else if(ev->button == Button3) {
|
||||
if(ev->state & MODKEY)
|
||||
toggletag(&a);
|
||||
toggletag(buf);
|
||||
else
|
||||
toggleview(&a);
|
||||
toggleview(buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if((ev->x < x + bmw) && (ev->button == Button1))
|
||||
togglemode(NULL);
|
||||
if(ev->x < x + blw)
|
||||
switch(ev->button) {
|
||||
case Button1:
|
||||
setlayout(NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((c = getclient(ev->window))) {
|
||||
focus(c);
|
||||
if(CLEANMASK(ev->state) != MODKEY)
|
||||
return;
|
||||
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||
if(ev->button == Button1 && (lt->arrange == floating || c->isfloating)) {
|
||||
restack();
|
||||
movemouse(c);
|
||||
}
|
||||
else if(ev->button == Button2)
|
||||
zoom(NULL);
|
||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
|
||||
!c->isfixed) {
|
||||
else if(ev->button == Button3
|
||||
&& (lt->arrange == floating || c->isfloating) && !c->isfixed)
|
||||
{
|
||||
restack();
|
||||
resizemouse(c);
|
||||
}
|
||||
@ -154,42 +168,31 @@ buttonpress(XEvent *e) {
|
||||
|
||||
static void
|
||||
configurerequest(XEvent *e) {
|
||||
unsigned long newmask;
|
||||
Client *c;
|
||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XWindowChanges wc;
|
||||
|
||||
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)
|
||||
c->y = ev->y;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
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;
|
||||
wc.height = c->h;
|
||||
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
|
||||
if(newmask)
|
||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||
else
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat) {
|
||||
resize(c, False, TopLeft);
|
||||
if(!isvisible(c))
|
||||
ban(c);
|
||||
if(c->isfixed || c->isfloating || (lt->arrange == floating)) {
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
c->y = ev->y;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->h = ev->height;
|
||||
if((ev->value_mask & (CWX | CWY))
|
||||
&& !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
configure(c);
|
||||
if(isvisible(c))
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
}
|
||||
else
|
||||
arrange();
|
||||
configure(c);
|
||||
}
|
||||
else {
|
||||
wc.x = ev->x;
|
||||
@ -200,8 +203,8 @@ configurerequest(XEvent *e) {
|
||||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -220,45 +223,40 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keypress(XEvent *e) {
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
static unsigned int len = sizeof key / sizeof key[0];
|
||||
unsigned int i;
|
||||
KeySym keysym;
|
||||
XKeyEvent *ev = &e->xkey;
|
||||
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
for(i = 0; i < len; i++) {
|
||||
for(i = 0; i < len; i++)
|
||||
if(keysym == key[i].keysym
|
||||
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||
{
|
||||
if(key[i].func)
|
||||
key[i].func(&key[i].arg);
|
||||
return;
|
||||
key[i].func(key[i].arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -266,8 +264,8 @@ leavenotify(XEvent *e) {
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
|
||||
if((ev->window == root) && !ev->same_screen) {
|
||||
issel = False;
|
||||
drawall();
|
||||
selscreen = False;
|
||||
focus(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,11 +285,8 @@ maprequest(XEvent *e) {
|
||||
|
||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||
return;
|
||||
if(wa.override_redirect) {
|
||||
XSelectInput(dpy, ev->window,
|
||||
(StructureNotifyMask | PropertyChangeMask));
|
||||
if(wa.override_redirect)
|
||||
return;
|
||||
}
|
||||
if(!getclient(ev->window))
|
||||
manage(ev->window, &wa);
|
||||
}
|
||||
@ -305,25 +300,21 @@ 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:
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
||||
arrange();
|
||||
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
||||
lt->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -355,7 +346,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
||||
|
||||
void
|
||||
grabkeys(void) {
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
static unsigned int len = sizeof key / sizeof key[0];
|
||||
unsigned int i;
|
||||
KeyCode code;
|
||||
|
||||
@ -372,14 +363,3 @@ grabkeys(void) {
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
procevent(void) {
|
||||
XEvent ev;
|
||||
|
||||
while(XPending(dpy)) {
|
||||
XNextEvent(dpy, &ev);
|
||||
if(handler[ev.type])
|
||||
(handler[ev.type])(&ev); /* call handler */
|
||||
}
|
||||
}
|
||||
|
255
layout.c
Normal file
255
layout.c
Normal file
@ -0,0 +1,255 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned int blw = 0;
|
||||
Layout *lt = NULL;
|
||||
|
||||
/* static */
|
||||
|
||||
static unsigned int nlayouts = 0;
|
||||
static unsigned int masterw = MASTERWIDTH;
|
||||
static unsigned int nmaster = NMASTER;
|
||||
|
||||
static void
|
||||
tile(void) {
|
||||
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
/* window geoms */
|
||||
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
|
||||
mw = (n > nmaster) ? (waw * masterw) / 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->isbanned)
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
if(c->isfloating)
|
||||
continue;
|
||||
c->ismax = False;
|
||||
nx = wax;
|
||||
ny = way;
|
||||
if(i < nmaster) {
|
||||
ny += i * mh;
|
||||
nw = mw - 2 * BORDERPX;
|
||||
nh = mh - 2 * BORDERPX;
|
||||
}
|
||||
else { /* tile window */
|
||||
nx += mw;
|
||||
nw = tw - 2 * BORDERPX;
|
||||
if(th > 2 * BORDERPX) {
|
||||
ny += (i - nmaster) * th;
|
||||
nh = th - 2 * BORDERPX;
|
||||
}
|
||||
else /* fallback if th <= 2 * BORDERPX */
|
||||
nh = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, nx, ny, nw, nh, False);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
c->isbanned = True;
|
||||
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);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
LAYOUTS
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
floating(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
if(c->isbanned)
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
resize(c, c->x, c->y, c->w, c->h, True);
|
||||
}
|
||||
else {
|
||||
c->isbanned = True;
|
||||
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);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
void
|
||||
focusclient(const char *arg) {
|
||||
Client *c;
|
||||
|
||||
if(!sel || !arg)
|
||||
return;
|
||||
if(atoi(arg) < 0) {
|
||||
for(c = sel->prev; c && !isvisible(c); c = c->prev);
|
||||
if(!c) {
|
||||
for(c = clients; c && c->next; c = c->next);
|
||||
for(; c && !isvisible(c); c = c->prev);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(c = sel->next; c && !isvisible(c); c = c->next);
|
||||
if(!c)
|
||||
for(c = clients; c && !isvisible(c); c = c->next);
|
||||
}
|
||||
if(c) {
|
||||
focus(c);
|
||||
restack();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
incmasterw(const char *arg) {
|
||||
int i;
|
||||
if(lt->arrange != tile)
|
||||
return;
|
||||
if(!arg)
|
||||
masterw = MASTERWIDTH;
|
||||
else {
|
||||
i = atoi(arg);
|
||||
if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
|
||||
|| waw * (masterw + i) / 1000 <= 2 * BORDERPX)
|
||||
return;
|
||||
masterw += i;
|
||||
}
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(!arg)
|
||||
nmaster = NMASTER;
|
||||
else {
|
||||
i = atoi(arg);
|
||||
if((lt->arrange != tile) || (nmaster + i < 1)
|
||||
|| (wah / (nmaster + i) <= 2 * BORDERPX))
|
||||
return;
|
||||
nmaster += i;
|
||||
}
|
||||
if(sel)
|
||||
lt->arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
initlayouts(void) {
|
||||
unsigned int i, w;
|
||||
|
||||
lt = &layout[0];
|
||||
nlayouts = sizeof layout / sizeof layout[0];
|
||||
for(blw = i = 0; i < nlayouts; i++) {
|
||||
w = textw(layout[i].symbol);
|
||||
if(w > blw)
|
||||
blw = w;
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
nexttiled(Client *c) {
|
||||
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
restack(void) {
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
drawstatus();
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->isfloating || lt->arrange == floating)
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
if(lt->arrange != floating) {
|
||||
if(!sel->isfloating)
|
||||
XLowerWindow(dpy, sel->win);
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
if(c == sel)
|
||||
continue;
|
||||
XLowerWindow(dpy, c->win);
|
||||
}
|
||||
}
|
||||
XSync(dpy, False);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
setlayout(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(!arg) {
|
||||
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
|
||||
if(i == nlayouts - 1)
|
||||
lt = &layout[0];
|
||||
else
|
||||
lt = &layout[++i];
|
||||
}
|
||||
else {
|
||||
i = atoi(arg);
|
||||
if(i < 0 || i >= nlayouts)
|
||||
return;
|
||||
lt = &layout[i];
|
||||
}
|
||||
if(sel)
|
||||
lt->arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
togglemax(const char *arg) {
|
||||
XEvent ev;
|
||||
|
||||
if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
|
||||
return;
|
||||
if((sel->ismax = !sel->ismax)) {
|
||||
sel->rx = sel->x;
|
||||
sel->ry = sel->y;
|
||||
sel->rw = sel->w;
|
||||
sel->rh = sel->h;
|
||||
resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
|
||||
}
|
||||
else
|
||||
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
|
||||
drawstatus();
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
zoom(const char *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
if(!sel || lt->arrange != tile || sel->isfloating)
|
||||
return;
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
return;
|
||||
detach(c);
|
||||
attach(c);
|
||||
focus(c);
|
||||
lt->arrange();
|
||||
}
|
213
main.c
213
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,12 @@
|
||||
|
||||
/* extern */
|
||||
|
||||
char stext[1024];
|
||||
Bool *seltag;
|
||||
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, ntags, numlockmask;
|
||||
char stext[256];
|
||||
int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int bh, ntags, numlockmask;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
Bool issel = True;
|
||||
Bool *seltag;
|
||||
Bool selscreen = True;
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
Client *stack = NULL;
|
||||
@ -35,13 +35,15 @@ Window root, barwin;
|
||||
|
||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||
static Bool otherwm, readin;
|
||||
static Bool running = True;
|
||||
|
||||
static void
|
||||
cleanup(void) {
|
||||
close(STDIN_FILENO);
|
||||
while(sel) {
|
||||
resize(sel, True, TopLeft);
|
||||
unmanage(sel);
|
||||
while(stack) {
|
||||
if(stack->isbanned)
|
||||
XMoveWindow(dpy, stack->win, stack->x, stack->y);
|
||||
unmanage(stack);
|
||||
}
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
@ -51,11 +53,65 @@ 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);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
initcolor(const char *colstr) {
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
XColor color;
|
||||
|
||||
if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
|
||||
eprint("error, cannot allocate color '%s'\n", colstr);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
static void
|
||||
initfont(const char *fontstr) {
|
||||
char *def, **missing;
|
||||
int i, n;
|
||||
|
||||
missing = NULL;
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
if(missing) {
|
||||
while(n--)
|
||||
fprintf(stderr, "missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
}
|
||||
if(dc.font.set) {
|
||||
XFontSetExtents *font_extents;
|
||||
XFontStruct **xfonts;
|
||||
char **font_names;
|
||||
dc.font.ascent = dc.font.descent = 0;
|
||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||
for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
|
||||
if(dc.font.ascent < (*xfonts)->ascent)
|
||||
dc.font.ascent = (*xfonts)->ascent;
|
||||
if(dc.font.descent < (*xfonts)->descent)
|
||||
dc.font.descent = (*xfonts)->descent;
|
||||
xfonts++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(dc.font.xfont)
|
||||
XFreeFont(dpy, dc.font.xfont);
|
||||
dc.font.xfont = NULL;
|
||||
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;
|
||||
}
|
||||
dc.font.height = dc.font.ascent + dc.font.descent;
|
||||
}
|
||||
|
||||
static void
|
||||
scan(void) {
|
||||
unsigned int i, num;
|
||||
@ -65,9 +121,8 @@ scan(void) {
|
||||
wins = NULL;
|
||||
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||
for(i = 0; i < num; i++) {
|
||||
if(!XGetWindowAttributes(dpy, wins[i], &wa))
|
||||
continue;
|
||||
if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||
if(!XGetWindowAttributes(dpy, wins[i], &wa)
|
||||
|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||
continue;
|
||||
if(wa.map_state == IsViewable)
|
||||
manage(wins[i], &wa);
|
||||
@ -88,6 +143,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,
|
||||
@ -97,63 +153,62 @@ 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 (i = 0; i < 8; i++)
|
||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||
if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
||||
== XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||
numlockmask = (1 << i);
|
||||
}
|
||||
}
|
||||
XFree(modmap);
|
||||
XFreeModifiermap(modmap);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||
grabkeys();
|
||||
initrregs();
|
||||
compileregs();
|
||||
for(ntags = 0; tags[ntags]; ntags++);
|
||||
seltag = emallocz(sizeof(Bool) * ntags);
|
||||
seltag[0] = True;
|
||||
/* style */
|
||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||
setfont(FONT);
|
||||
dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR);
|
||||
dc.norm[ColBG] = initcolor(NORMBGCOLOR);
|
||||
dc.norm[ColFG] = initcolor(NORMFGCOLOR);
|
||||
dc.sel[ColBorder] = initcolor(SELBORDERCOLOR);
|
||||
dc.sel[ColBG] = initcolor(SELBGCOLOR);
|
||||
dc.sel[ColFG] = initcolor(SELFGCOLOR);
|
||||
initfont(FONT);
|
||||
/* geometry */
|
||||
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
master = MASTER;
|
||||
initlayouts();
|
||||
/* 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),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
barwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? 0 : sh - bh), sw, bh, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
XMapRaised(dpy, barwin);
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* windowarea */
|
||||
wax = sx;
|
||||
way = sy + bh;
|
||||
way = sy + (TOPBAR ? bh : 0);
|
||||
wah = sh - bh;
|
||||
waw = sw;
|
||||
/* pixmap for everything */
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
if(!dc.font.set)
|
||||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||
/* multihead support */
|
||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -168,40 +223,8 @@ 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;
|
||||
|
||||
e.type = ClientMessage;
|
||||
e.xclient.window = w;
|
||||
e.xclient.message_type = a;
|
||||
e.xclient.format = 32;
|
||||
e.xclient.data.l[0] = value;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(dpy, w, False, NoEventMask, &e);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
quit(Arg *arg) {
|
||||
quit(const char *arg) {
|
||||
readin = running = False;
|
||||
}
|
||||
|
||||
@ -227,17 +250,17 @@ xerror(Display *dpy, XErrorEvent *ee) {
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char *p;
|
||||
int r, xfd;
|
||||
fd_set rd;
|
||||
XEvent ev;
|
||||
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3))
|
||||
eprint("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n");
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
dpy = XOpenDisplay(0);
|
||||
if(!dpy)
|
||||
setlocale(LC_CTYPE, "");
|
||||
if(!(dpy = XOpenDisplay(0)))
|
||||
eprint("dwm: cannot open display\n");
|
||||
xfd = ConnectionNumber(dpy);
|
||||
screen = DefaultScreen(dpy);
|
||||
@ -260,29 +283,41 @@ main(int argc, char *argv[]) {
|
||||
|
||||
/* main event loop, also reads status text from stdin */
|
||||
XSync(dpy, False);
|
||||
procevent();
|
||||
readin = True;
|
||||
while(running) {
|
||||
FD_ZERO(&rd);
|
||||
if(readin)
|
||||
FD_SET(STDIN_FILENO, &rd);
|
||||
FD_SET(xfd, &rd);
|
||||
r = select(xfd + 1, &rd, NULL, NULL, NULL);
|
||||
if((r == -1) && (errno == EINTR))
|
||||
continue;
|
||||
if(r > 0) {
|
||||
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
||||
if(readin)
|
||||
stext[strlen(stext) - 1] = 0;
|
||||
else
|
||||
strcpy(stext, "broken pipe");
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
else if(r < 0)
|
||||
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
|
||||
if(errno == EINTR)
|
||||
continue;
|
||||
eprint("select failed\n");
|
||||
procevent();
|
||||
}
|
||||
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
|
||||
case -1:
|
||||
strncpy(stext, strerror(errno), sizeof stext - 1);
|
||||
stext[sizeof stext - 1] = '\0';
|
||||
readin = False;
|
||||
break;
|
||||
case 0:
|
||||
strncpy(stext, "EOF", 4);
|
||||
readin = False;
|
||||
break;
|
||||
default:
|
||||
for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
|
||||
for(; p >= stext && *p != '\n'; --p);
|
||||
if(p > stext)
|
||||
strncpy(stext, p + 1, sizeof stext);
|
||||
}
|
||||
drawstatus();
|
||||
}
|
||||
while(XPending(dpy)) {
|
||||
XNextEvent(dpy, &ev);
|
||||
if(handler[ev.type])
|
||||
(handler[ev.type])(&ev); /* call handler */
|
||||
}
|
||||
}
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
|
138
tag.c
138
tag.c
@ -1,96 +1,91 @@
|
||||
/* (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 <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static */
|
||||
|
||||
typedef struct {
|
||||
const char *clpattern;
|
||||
const char *tpattern;
|
||||
Bool isfloat;
|
||||
const char *prop;
|
||||
const char *tags;
|
||||
Bool isfloating;
|
||||
} Rule;
|
||||
|
||||
typedef struct {
|
||||
regex_t *clregex;
|
||||
regex_t *tregex;
|
||||
} RReg;
|
||||
|
||||
/* static */
|
||||
regex_t *propregex;
|
||||
regex_t *tagregex;
|
||||
} Regs;
|
||||
|
||||
TAGS
|
||||
RULES
|
||||
|
||||
static RReg *rreg = NULL;
|
||||
static unsigned int len = 0;
|
||||
static Regs *regs = NULL;
|
||||
static unsigned int nrules = 0;
|
||||
|
||||
/* extern */
|
||||
|
||||
Client *
|
||||
getnext(Client *c) {
|
||||
for(; c && !isvisible(c); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
Client *
|
||||
getprev(Client *c) {
|
||||
for(; c && !isvisible(c); c = c->prev);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
initrregs(void) {
|
||||
compileregs(void) {
|
||||
unsigned int i;
|
||||
regex_t *reg;
|
||||
|
||||
if(rreg)
|
||||
if(regs)
|
||||
return;
|
||||
len = sizeof(rule) / sizeof(rule[0]);
|
||||
rreg = emallocz(len * sizeof(RReg));
|
||||
for(i = 0; i < len; i++) {
|
||||
if(rule[i].clpattern) {
|
||||
nrules = sizeof rule / sizeof rule[0];
|
||||
regs = emallocz(nrules * sizeof(Regs));
|
||||
for(i = 0; i < nrules; i++) {
|
||||
if(rule[i].prop) {
|
||||
reg = emallocz(sizeof(regex_t));
|
||||
if(regcomp(reg, rule[i].clpattern, 0))
|
||||
if(regcomp(reg, rule[i].prop, REG_EXTENDED))
|
||||
free(reg);
|
||||
else
|
||||
rreg[i].clregex = reg;
|
||||
regs[i].propregex = reg;
|
||||
}
|
||||
if(rule[i].tpattern) {
|
||||
if(rule[i].tags) {
|
||||
reg = emallocz(sizeof(regex_t));
|
||||
if(regcomp(reg, rule[i].tpattern, 0))
|
||||
if(regcomp(reg, rule[i].tags, REG_EXTENDED))
|
||||
free(reg);
|
||||
else
|
||||
rreg[i].tregex = reg;
|
||||
regs[i].tagregex = reg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
isvisible(Client *c) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
if(c->tags[i] && seltag[i])
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
void
|
||||
settags(Client *c, Client *trans) {
|
||||
char prop[512];
|
||||
unsigned int i, j;
|
||||
regmatch_t tmp;
|
||||
Bool matched = trans != NULL;
|
||||
XClassHint ch;
|
||||
XClassHint ch = { 0 };
|
||||
|
||||
if(matched) {
|
||||
if(matched)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = trans->tags[i];
|
||||
}
|
||||
else if(XGetClassHint(dpy, c->win, &ch)) {
|
||||
snprintf(prop, sizeof(prop), "%s:%s:%s",
|
||||
else {
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
snprintf(prop, sizeof prop, "%s:%s:%s",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
ch.res_name ? ch.res_name : "", c->name);
|
||||
for(i = 0; !matched && i < len; i++)
|
||||
if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
|
||||
c->isfloat = rule[i].isfloat;
|
||||
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
||||
if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
|
||||
for(i = 0; i < nrules; i++)
|
||||
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
|
||||
c->isfloating = rule[i].isfloating;
|
||||
for(j = 0; regs[i].tagregex && j < ntags; j++) {
|
||||
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
|
||||
matched = True;
|
||||
c->tags[j] = True;
|
||||
}
|
||||
@ -107,26 +102,53 @@ settags(Client *c, Client *trans) {
|
||||
}
|
||||
|
||||
void
|
||||
tag(Arg *arg) {
|
||||
unsigned int i;
|
||||
tag(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
for(i = 0; i < ntags; i++)
|
||||
sel->tags[i] = False;
|
||||
sel->tags[arg->i] = True;
|
||||
arrange();
|
||||
sel->tags[i] = arg == NULL;
|
||||
i = arg ? atoi(arg) : 0;
|
||||
if(i >= 0 && i < ntags)
|
||||
sel->tags[i] = True;
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
toggletag(Arg *arg) {
|
||||
unsigned int i;
|
||||
toggletag(const char *arg) {
|
||||
int i, j;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
sel->tags[arg->i] = !sel->tags[arg->i];
|
||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||
if(i == ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
arrange();
|
||||
i = arg ? atoi(arg) : 0;
|
||||
sel->tags[i] = !sel->tags[i];
|
||||
for(j = 0; j < ntags && !sel->tags[j]; j++);
|
||||
if(j == ntags)
|
||||
sel->tags[i] = True;
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
toggleview(const char *arg) {
|
||||
int i, j;
|
||||
|
||||
i = arg ? atoi(arg) : 0;
|
||||
seltag[i] = !seltag[i];
|
||||
for(j = 0; j < ntags && !seltag[j]; j++);
|
||||
if(j == ntags)
|
||||
seltag[i] = True; /* cannot toggle last view */
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
view(const char *arg) {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = arg == NULL;
|
||||
i = arg ? atoi(arg) : 0;
|
||||
if(i >= 0 && i < ntags)
|
||||
seltag[i] = True;
|
||||
lt->arrange();
|
||||
}
|
||||
|
19
util.c
19
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,22 +29,13 @@ 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) {
|
||||
spawn(const char *arg) {
|
||||
static char *shell = NULL;
|
||||
|
||||
if(!shell && !(shell = getenv("SHELL")))
|
||||
shell = "/bin/sh";
|
||||
if(!arg->cmd)
|
||||
if(!arg)
|
||||
return;
|
||||
/* The double-fork construct avoids zombie processes and keeps the code
|
||||
* clean from stupid signal handlers. */
|
||||
@ -53,8 +44,8 @@ spawn(Arg *arg) {
|
||||
if(dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
setsid();
|
||||
execl(shell, shell, "-c", arg->cmd, (char *)NULL);
|
||||
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
|
||||
execl(shell, shell, "-c", arg, (char *)NULL);
|
||||
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
|
||||
perror(" failed");
|
||||
}
|
||||
exit(0);
|
||||
|
268
view.c
268
view.c
@ -1,268 +0,0 @@
|
||||
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
/* static */
|
||||
|
||||
static Client *
|
||||
nexttiled(Client *c) {
|
||||
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
togglemax(Client *c) {
|
||||
XEvent ev;
|
||||
|
||||
if(c->isfixed)
|
||||
return;
|
||||
|
||||
if((c->ismax = !c->ismax)) {
|
||||
c->rx = c->x; c->x = wax;
|
||||
c->ry = c->y; c->y = way;
|
||||
c->rw = c->w; c->w = waw - 2 * BORDERPX;
|
||||
c->rh = c->h; c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else {
|
||||
c->x = c->rx;
|
||||
c->y = c->ry;
|
||||
c->w = c->rw;
|
||||
c->h = c->rh;
|
||||
}
|
||||
resize(c, True, TopLeft);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void (*arrange)(void) = DEFMODE;
|
||||
|
||||
void
|
||||
detach(Client *c) {
|
||||
if(c->prev)
|
||||
c->prev->next = c->next;
|
||||
if(c->next)
|
||||
c->next->prev = c->prev;
|
||||
if(c == clients)
|
||||
clients = c->next;
|
||||
c->next = c->prev = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
dofloat(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
resize(c, True, TopLeft);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
}
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
void
|
||||
dotile(void) {
|
||||
unsigned int i, n, mpx, stackw, th;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
mpx = (waw * master) / 1000;
|
||||
stackw = waw - mpx;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isfloat) {
|
||||
resize(c, True, TopLeft);
|
||||
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 = waw - stackw - 2 * BORDERPX;
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
th = wah / (n - 1);
|
||||
}
|
||||
else { /* tile window */
|
||||
c->x += mpx;
|
||||
c->w = stackw - 2 * BORDERPX;
|
||||
if(th > bh) {
|
||||
c->y = way + (i - 1) * th;
|
||||
c->h = th - 2 * BORDERPX;
|
||||
}
|
||||
else /* fallback if th < bh */
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
restack();
|
||||
}
|
||||
|
||||
void
|
||||
focusnext(Arg *arg) {
|
||||
Client *c;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(!(c = getnext(sel->next)))
|
||||
c = getnext(clients);
|
||||
if(c) {
|
||||
focus(c);
|
||||
restack();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
focusprev(Arg *arg) {
|
||||
Client *c;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(!(c = getprev(sel->prev))) {
|
||||
for(c = clients; c && c->next; c = c->next);
|
||||
c = getprev(c);
|
||||
}
|
||||
if(c) {
|
||||
focus(c);
|
||||
restack();
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
isvisible(Client *c) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
if(c->tags[i] && seltag[i])
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
void
|
||||
resizemaster(Arg *arg) {
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(master + arg->i > 950 || master + arg->i < 50)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
restack(void) {
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel) {
|
||||
drawstatus();
|
||||
return;
|
||||
}
|
||||
if(sel->isfloat || arrange == dofloat) {
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
XRaiseWindow(dpy, sel->twin);
|
||||
}
|
||||
if(arrange != dofloat) {
|
||||
if(!sel->isfloat) {
|
||||
XLowerWindow(dpy, sel->twin);
|
||||
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));
|
||||
}
|
||||
|
||||
void
|
||||
togglemode(Arg *arg) {
|
||||
arrange = (arrange == dofloat) ? dotile : dofloat;
|
||||
if(sel)
|
||||
arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
toggleview(Arg *arg) {
|
||||
unsigned int i;
|
||||
|
||||
seltag[arg->i] = !seltag[arg->i];
|
||||
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||
if(i == ntags)
|
||||
seltag[arg->i] = True; /* cannot toggle last view */
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
view(Arg *arg) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = False;
|
||||
seltag[arg->i] = True;
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
viewall(Arg *arg) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = True;
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
zoom(Arg *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->isfloat || (arrange == dofloat)) {
|
||||
togglemax(sel);
|
||||
return;
|
||||
}
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c) && !c->isfloat)
|
||||
n++;
|
||||
if(n < 2 || (arrange == dofloat))
|
||||
return;
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
return;
|
||||
detach(c);
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
clients = c;
|
||||
focus(c);
|
||||
arrange();
|
||||
}
|
Reference in New Issue
Block a user