Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
22399a3bc0 | |||
ad2508f957 | |||
b078599833 | |||
1e80207876 | |||
464fc2cd18 | |||
be8d6d40f6 | |||
f0c2353393 | |||
a730213c3b | |||
399993c6b5 | |||
4d318060a2 | |||
540d5eed46 | |||
7d071ce2bd | |||
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 |
4
.hgtags
4
.hgtags
@ -38,3 +38,7 @@ d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
9ede7b2d2450537e750d5505789fbe63960e97e6 3.4
|
||||
63ad05e7f9e1f4f1881fb02f529cb6c6ae81e693 3.5
|
||||
75b1b25fe0d7e29400baf30568153f668324928b 3.6
|
||||
20ec6976cee1fcfee0c2f354ae382ee3f9f68efa 3.6.1
|
||||
baee494346e520f8dee2cee9491b8350064770d2 3.7
|
||||
2ea201354cf016407ea93e1e390d1422940d29b0 3.8
|
||||
55478328b2422c700c5404a774c85e77322f41a3 3.9
|
||||
|
4
LICENSE
4
LICENSE
@ -1,7 +1,7 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
(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>
|
||||
© 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
# dwm - dynamic window manager
|
||||
# (C)opyright MMVI-MMVII Anselm R. Garbe
|
||||
# © 2006-2007 Anselm R. Garbe, Sander van Dijk
|
||||
|
||||
include config.mk
|
||||
|
||||
|
157
client.c
157
client.c
@ -1,6 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -83,24 +83,6 @@ setclientstate(Client *c, long state) {
|
||||
PropModeReplace, (unsigned char *)data, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
togglemax(Client *c) {
|
||||
XEvent ev;
|
||||
|
||||
if(c->isfixed)
|
||||
return;
|
||||
if((c->ismax = !c->ismax)) {
|
||||
c->rx = c->x;
|
||||
c->ry = c->y;
|
||||
c->rw = c->w;
|
||||
c->rh = c->h;
|
||||
resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
|
||||
}
|
||||
else
|
||||
resize(c, c->rx, c->ry, c->rw, c->rh, True);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
static int
|
||||
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
return 0;
|
||||
@ -171,19 +153,29 @@ focus(Client *c) {
|
||||
}
|
||||
|
||||
void
|
||||
killclient(Arg *arg) {
|
||||
killclient(const char *arg) {
|
||||
XEvent ev;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(isprotodel(sel))
|
||||
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, *t;
|
||||
Client *c, *t = NULL;
|
||||
Window trans;
|
||||
Status rettrans;
|
||||
XWindowChanges wc;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
@ -193,13 +185,13 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->y = wa->y;
|
||||
c->w = wa->width;
|
||||
c->h = wa->height;
|
||||
c->oldborder = wa->border_width;
|
||||
if(c->w == sw && c->h == sh) {
|
||||
c->border = 0;
|
||||
c->x = sx;
|
||||
c->y = sy;
|
||||
c->border = wa->border_width;
|
||||
}
|
||||
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)
|
||||
@ -208,21 +200,22 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->x = wax;
|
||||
if(c->y < way)
|
||||
c->y = way;
|
||||
c->border = BORDERPX;
|
||||
}
|
||||
updatesizehints(c);
|
||||
XSelectInput(dpy, w,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
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 */
|
||||
updatesizehints(c);
|
||||
XSelectInput(dpy, w,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
grabbuttons(c, False);
|
||||
updatetitle(c);
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
settags(c, t);
|
||||
if(!c->isversatile)
|
||||
c->isversatile = (t != NULL) || c->isfixed;
|
||||
if(!c->isfloating)
|
||||
c->isfloating = (rettrans == Success) || c->isfixed;
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
c->isbanned = True;
|
||||
@ -236,12 +229,33 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
|
||||
void
|
||||
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
float actual, dx, dy, max, min;
|
||||
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)
|
||||
@ -250,37 +264,13 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
w = c->maxw;
|
||||
if(c->maxh && h > c->maxh)
|
||||
h = c->maxh;
|
||||
/* inspired by algorithm from fluxbox */
|
||||
if(c->minay > 0 && c->maxay && (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);
|
||||
actual = dx / dy;
|
||||
if(max > 0 && min > 0 && actual > 0) {
|
||||
if(actual < min) {
|
||||
dy = (dx * min + dy) / (min * min + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
else if(actual > max) {
|
||||
dy = (dx * min + dy) / (max * max + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c->incw)
|
||||
w -= (w - c->basew) % c->incw;
|
||||
if(c->inch)
|
||||
h -= (h - c->baseh) % c->inch;
|
||||
}
|
||||
if(w == sw && h == sh)
|
||||
c->border = 0;
|
||||
else
|
||||
c->border = BORDERPX;
|
||||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
/* offscreen appearance fixes */
|
||||
if(x > sw)
|
||||
x = sw - w - 2 * c->border;
|
||||
@ -303,10 +293,10 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
}
|
||||
|
||||
void
|
||||
toggleversatile(Arg *arg) {
|
||||
if(!sel || lt->arrange == versatile)
|
||||
togglefloating(const char *arg) {
|
||||
if(!sel || lt->arrange == floating)
|
||||
return;
|
||||
sel->isversatile = !sel->isversatile;
|
||||
sel->isfloating = !sel->isfloating;
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
@ -322,6 +312,10 @@ updatesizehints(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) {
|
||||
@ -340,16 +334,20 @@ updatesizehints(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;
|
||||
if(c->flags & PAspect) {
|
||||
c->minax = size.min_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxax = size.max_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxay = size.max_aspect.y;
|
||||
}
|
||||
else
|
||||
c->minax = c->minay = c->maxax = c->maxay = 0;
|
||||
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);
|
||||
}
|
||||
@ -383,10 +381,13 @@ updatetitle(Client *c) {
|
||||
void
|
||||
unmanage(Client *c) {
|
||||
Client *nc;
|
||||
XWindowChanges wc;
|
||||
|
||||
wc.border_width = c->oldborder;
|
||||
/* The server grab construct avoids race conditions. */
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
if(sel == c) {
|
||||
@ -402,25 +403,3 @@ unmanage(Client *c) {
|
||||
XUngrabServer(dpy);
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
zoom(Arg *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->isversatile || (lt->arrange == versatile)) {
|
||||
togglemax(sel);
|
||||
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();
|
||||
}
|
||||
|
128
config.arg.h
128
config.arg.h
@ -1,25 +1,24 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
|
||||
/* appearance */
|
||||
#define BORDERPX 1
|
||||
#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*"
|
||||
#define FONT "-*-pixelcarnage monospace-*-r-*-*-14-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#333"
|
||||
#define NORMBGCOLOR "#222"
|
||||
#define NORMFGCOLOR "#ccc"
|
||||
#define SELBORDERCOLOR "#69c"
|
||||
#define SELBORDERCOLOR "#8c8"
|
||||
#define SELBGCOLOR "#555"
|
||||
#define SELFGCOLOR "#fff"
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
/* behavior */
|
||||
#define SNAP 40 /* pixel */
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isversatile */ \
|
||||
/* class:instance:title regex tags regex isfloating */ \
|
||||
{ "Firefox", "3", False }, \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
@ -31,69 +30,70 @@ static Rule rule[] = { \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", versatile }, \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define MASTER 600 /* per thousand */
|
||||
#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, \
|
||||
{ .cmd = "exec uxterm -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
|
||||
{ MODKEY, XK_p, spawn, \
|
||||
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
|
||||
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
|
||||
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, setlayout, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
|
||||
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||
{ 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, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
"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 }, \
|
||||
};
|
||||
|
118
config.default.h
118
config.default.h
@ -1,6 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
|
||||
/* appearance */
|
||||
#define BORDERPX 1
|
||||
@ -13,15 +13,14 @@
|
||||
#define SELFGCOLOR "#ffffff"
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
/* behavior */
|
||||
#define SNAP 20 /* pixel */
|
||||
/* tagging */
|
||||
#define TAGS \
|
||||
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 isversatile */ \
|
||||
/* class:instance:title regex tags regex isfloating */ \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
{ "Acroread", NULL, True }, \
|
||||
@ -32,64 +31,67 @@ static Rule rule[] = { \
|
||||
static Layout layout[] = { \
|
||||
/* symbol function */ \
|
||||
{ "[]=", tile }, /* first entry is default */ \
|
||||
{ "><>", versatile }, \
|
||||
{ "><>", floating }, \
|
||||
};
|
||||
#define MASTER 600 /* per thousand */
|
||||
#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, { .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, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, setlayout, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
|
||||
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||
{ 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, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||
{ MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
{ 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 = 3.6.1
|
||||
VERSION = 4.0
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
25
draw.c
25
draw.c
@ -1,6 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -79,7 +79,12 @@ drawstatus(void) {
|
||||
drawtext(stext, dc.norm);
|
||||
if((dc.w = dc.x - x) > bh) {
|
||||
dc.x = x;
|
||||
drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm);
|
||||
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);
|
||||
@ -90,7 +95,6 @@ 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]);
|
||||
@ -119,16 +123,11 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
}
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = col[ColFG];
|
||||
if(dc.font.set) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||
XSetForeground(dpy, dc.gc, col[ColFG]);
|
||||
if(dc.font.set)
|
||||
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);
|
||||
else
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
|
103
dwm.1
103
dwm.1
@ -1,29 +1,31 @@
|
||||
.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
|
||||
versatile layouts. Either layout 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 layout windows are managed in a master and stacking area. The master
|
||||
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 versatile layout windows can be
|
||||
resized and moved freely. Dialog windows are always managed versatile,
|
||||
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 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 layout,
|
||||
the title of the focused window, and the text read from standard input. The
|
||||
selected tags are indicated with a different color. The tags of the focused
|
||||
window are indicated with a filled square in the top left corner. The tags
|
||||
which are applied to one or more windows are indicated with an empty square in
|
||||
the top left corner.
|
||||
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 small border around windows to indicate the focus state.
|
||||
.SH OPTIONS
|
||||
@ -38,96 +40,93 @@ 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 layout
|
||||
label toggles between tiling and versatile 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 Button4
|
||||
click on the layout label increases the number of windows in the master area (tiling layout only).
|
||||
.TP
|
||||
.B Button5
|
||||
click on the layout label decreases the number of windows in the master area (tiling layout only).
|
||||
.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 layout), toggles maximization of current window (versatile layout).
|
||||
.B Mod1\-Shift\-j
|
||||
Increase the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-g
|
||||
Grow master area (tiling layout 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 layout only).
|
||||
.B Mod1\-l
|
||||
Increase master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-i
|
||||
Increase the number of windows in the master area (tiling layout only).
|
||||
.B Mod1\-h
|
||||
Decrease master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-d
|
||||
Decrease the number of windows in the master area (tiling layout only).
|
||||
.B Mod1\-m
|
||||
Toggles maximization of current window (floating layout only).
|
||||
.TP
|
||||
.B Mod1-Shift-[1..n]
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply
|
||||
.RB nth
|
||||
tag to current window.
|
||||
.TP
|
||||
.B Mod1-Shift-0
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to current window.
|
||||
.TP
|
||||
.B Mod1-Control-Shift-[1..n]
|
||||
.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 versatile layout (affects all windows).
|
||||
.B Mod1\-space
|
||||
Toggle between tiled and floating layout (affects all windows).
|
||||
.TP
|
||||
.B Mod1-Shift-space
|
||||
Toggle focused window between versatile and non-versatile state (tiling layout only).
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-[1..n]
|
||||
.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 (versatile layout only).
|
||||
.B Mod1\-Button1
|
||||
Move current window while dragging (floating layout only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
Zooms/cycles current window to/from master area (tiling layout), toggles maximization of current window (versatile layout).
|
||||
.B Mod1\-Button2
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
Resize current window while dragging (versatile layout 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.
|
||||
|
152
dwm.h
152
dwm.h
@ -1,4 +1,5 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* dynamic window manager is designed like any other X client as well. It is
|
||||
@ -41,38 +42,16 @@ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
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];
|
||||
Drawable drawable;
|
||||
Fnt font;
|
||||
GC gc;
|
||||
} DC; /* draw context */
|
||||
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
char name[256];
|
||||
int x, y, w, h;
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int minax, minay, maxax, maxay;
|
||||
int minax, maxax, minay, maxay;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isbanned, isfixed, ismax, isversatile;
|
||||
unsigned int border, oldborder;
|
||||
Bool isbanned, isfixed, ismax, isfloating;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
Client *prev;
|
||||
@ -80,77 +59,90 @@ struct Client {
|
||||
Window win;
|
||||
};
|
||||
|
||||
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 */
|
||||
extern char stext[256]; /* status text */
|
||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern unsigned int bh, blw; /* bar height, bar layout label width */
|
||||
extern unsigned int master, nmaster; /* master percent, number of master clients */
|
||||
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool selscreen, *seltag; /* seltag is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc; /* global draw context */
|
||||
extern Display *dpy;
|
||||
extern Layout *lt;
|
||||
extern Window root, barwin;
|
||||
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 configure(Client *c); /* send synthetic configure event */
|
||||
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||
extern void killclient(Arg *arg); /* kill c nicely */
|
||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
extern void resize(Client *c, int x, int y,
|
||||
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*/
|
||||
extern void toggleversatile(Arg *arg); /* toggles focused client between versatile/and non-versatile state */
|
||||
extern void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
extern void updatetitle(Client *c); /* update the name of c */
|
||||
extern void unmanage(Client *c); /* destroy c */
|
||||
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
|
||||
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 drawstatus(void); /* draw the bar */
|
||||
extern void drawtext(const char *text,
|
||||
unsigned long col[ColLast]); /* draw text */
|
||||
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 */
|
||||
void grabkeys(void); /* grab all keys defined in config.h */
|
||||
|
||||
/* layout.c */
|
||||
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
|
||||
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
|
||||
extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
|
||||
extern void initlayouts(void); /* initialize layout array */
|
||||
extern Client *nexttiled(Client *c); /* returns tiled successor of c */
|
||||
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 setlayout(Arg *arg); /* sets layout, -1 toggles */
|
||||
extern void versatile(void); /* arranges all windows versatile */
|
||||
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 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 compileregs(void); /* initialize regexps of rules defined in config.h */
|
||||
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
||||
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 */
|
||||
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 */
|
||||
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 spawn(Arg *arg); /* forks a new subprocess with arg's cmd */
|
||||
|
||||
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 */
|
||||
|
50
event.c
50
event.c
@ -1,7 +1,8 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk 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
|
||||
@ -112,27 +113,29 @@ 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;
|
||||
}
|
||||
@ -140,16 +143,7 @@ buttonpress(XEvent *e) {
|
||||
if(ev->x < x + blw)
|
||||
switch(ev->button) {
|
||||
case Button1:
|
||||
a.i = -1;
|
||||
setlayout(&a);
|
||||
break;
|
||||
case Button4:
|
||||
a.i = 1;
|
||||
incnmaster(&a);
|
||||
break;
|
||||
case Button5:
|
||||
a.i = -1;
|
||||
incnmaster(&a);
|
||||
setlayout(NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -157,14 +151,14 @@ buttonpress(XEvent *e) {
|
||||
focus(c);
|
||||
if(CLEANMASK(ev->state) != MODKEY)
|
||||
return;
|
||||
if(ev->button == Button1 && (lt->arrange == versatile || c->isversatile)) {
|
||||
if(ev->button == Button1 && (lt->arrange == floating || c->isfloating)) {
|
||||
restack();
|
||||
movemouse(c);
|
||||
}
|
||||
else if(ev->button == Button2)
|
||||
zoom(NULL);
|
||||
else if(ev->button == Button3
|
||||
&& (lt->arrange == versatile || c->isversatile) && !c->isfixed)
|
||||
&& (lt->arrange == floating || c->isfloating) && !c->isfixed)
|
||||
{
|
||||
restack();
|
||||
resizemouse(c);
|
||||
@ -182,7 +176,7 @@ configurerequest(XEvent *e) {
|
||||
c->ismax = False;
|
||||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
if(c->isfixed || c->isversatile || (lt->arrange == versatile)) {
|
||||
if(c->isfixed || c->isfloating || (lt->arrange == floating)) {
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
@ -261,7 +255,7 @@ keypress(XEvent *e) {
|
||||
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||
{
|
||||
if(key[i].func)
|
||||
key[i].func(&key[i].arg);
|
||||
key[i].func(key[i].arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +304,7 @@ propertynotify(XEvent *e) {
|
||||
default: break;
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
if(!c->isversatile && (c->isversatile = (getclient(trans) != NULL)))
|
||||
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
||||
lt->arrange();
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
|
200
layout.c
200
layout.c
@ -1,16 +1,17 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned int master = MASTER;
|
||||
unsigned int nmaster = NMASTER;
|
||||
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) {
|
||||
@ -21,7 +22,7 @@ tile(void) {
|
||||
n++;
|
||||
/* window geoms */
|
||||
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
|
||||
mw = (n > nmaster) ? (waw * master) / 1000 : waw;
|
||||
mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
|
||||
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
||||
tw = waw - mw;
|
||||
|
||||
@ -30,25 +31,25 @@ tile(void) {
|
||||
if(c->isbanned)
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
c->isbanned = False;
|
||||
if(c->isversatile)
|
||||
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;
|
||||
nw = mw - 2 * c->border;
|
||||
nh = mh - 2 * c->border;
|
||||
}
|
||||
else { /* tile window */
|
||||
nx += mw;
|
||||
nw = tw - 2 * BORDERPX;
|
||||
if(th > 2 * BORDERPX) {
|
||||
nw = tw - 2 * c->border;
|
||||
if(th > 2 * c->border) {
|
||||
ny += (i - nmaster) * th;
|
||||
nh = th - 2 * BORDERPX;
|
||||
nh = th - 2 * c->border;
|
||||
}
|
||||
else /* fallback if th <= 2 * BORDERPX */
|
||||
nh = wah - 2 * BORDERPX;
|
||||
else /* fallback if th <= 2 * c->border */
|
||||
nh = wah - 2 * c->border;
|
||||
}
|
||||
resize(c, nx, ny, nw, nh, False);
|
||||
i++;
|
||||
@ -69,30 +70,45 @@ LAYOUTS
|
||||
/* extern */
|
||||
|
||||
void
|
||||
focusnext(Arg *arg) {
|
||||
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)
|
||||
if(!sel || !arg)
|
||||
return;
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
focusprev(Arg *arg) {
|
||||
Client *c;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
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);
|
||||
@ -101,11 +117,35 @@ focusprev(Arg *arg) {
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(Arg *arg) {
|
||||
if((lt->arrange != tile) || (nmaster + arg->i < 1)
|
||||
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
||||
incmasterw(const char *arg) {
|
||||
int i;
|
||||
if(lt->arrange != tile)
|
||||
return;
|
||||
nmaster += arg->i;
|
||||
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
|
||||
@ -127,25 +167,10 @@ initlayouts(void) {
|
||||
|
||||
Client *
|
||||
nexttiled(Client *c) {
|
||||
for(; c && (c->isversatile || !isvisible(c)); c = c->next);
|
||||
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
resizemaster(Arg *arg) {
|
||||
if(lt->arrange != tile)
|
||||
return;
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
|
||||
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
lt->arrange();
|
||||
}
|
||||
|
||||
void
|
||||
restack(void) {
|
||||
Client *c;
|
||||
@ -154,10 +179,10 @@ restack(void) {
|
||||
drawstatus();
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->isversatile || lt->arrange == versatile)
|
||||
if(sel->isfloating || lt->arrange == floating)
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
if(lt->arrange != versatile) {
|
||||
if(!sel->isversatile)
|
||||
if(lt->arrange != floating) {
|
||||
if(!sel->isfloating)
|
||||
XLowerWindow(dpy, sel->win);
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
if(c == sel)
|
||||
@ -170,10 +195,10 @@ restack(void) {
|
||||
}
|
||||
|
||||
void
|
||||
setlayout(Arg *arg) {
|
||||
unsigned int i;
|
||||
setlayout(const char *arg) {
|
||||
int i;
|
||||
|
||||
if(arg->i == -1) {
|
||||
if(!arg) {
|
||||
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
|
||||
if(i == nlayouts - 1)
|
||||
lt = &layout[0];
|
||||
@ -181,9 +206,10 @@ setlayout(Arg *arg) {
|
||||
lt = &layout[++i];
|
||||
}
|
||||
else {
|
||||
if(arg->i < 0 || arg->i >= nlayouts)
|
||||
i = atoi(arg);
|
||||
if(i < 0 || i >= nlayouts)
|
||||
return;
|
||||
lt = &layout[arg->i];
|
||||
lt = &layout[i];
|
||||
}
|
||||
if(sel)
|
||||
lt->arrange();
|
||||
@ -192,24 +218,38 @@ setlayout(Arg *arg) {
|
||||
}
|
||||
|
||||
void
|
||||
versatile(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;
|
||||
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
40
main.c
40
main.c
@ -1,7 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
@ -82,7 +81,7 @@ initfont(const char *fontstr) {
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
if(missing) {
|
||||
while(n--)
|
||||
fprintf(stderr, "missing fontset: %s\n", missing[n]);
|
||||
fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
}
|
||||
if(dc.font.set) {
|
||||
@ -205,6 +204,8 @@ setup(void) {
|
||||
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 */
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
}
|
||||
@ -222,21 +223,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||
/* extern */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -268,7 +255,7 @@ main(int argc, char *argv[]) {
|
||||
XEvent ev;
|
||||
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3))
|
||||
eprint("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n");
|
||||
eprint("dwm-"VERSION", © 2004-2007 Anselm R. Garbe, Sander van Dijk\n");
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
setlocale(LC_CTYPE, "");
|
||||
@ -325,12 +312,11 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
drawstatus();
|
||||
}
|
||||
if(FD_ISSET(xfd, &rd))
|
||||
while(XPending(dpy)) {
|
||||
XNextEvent(dpy, &ev);
|
||||
if(handler[ev.type])
|
||||
(handler[ev.type])(&ev); /* call handler */
|
||||
}
|
||||
while(XPending(dpy)) {
|
||||
XNextEvent(dpy, &ev);
|
||||
if(handler[ev.type])
|
||||
(handler[ev.type])(&ev); /* call handler */
|
||||
}
|
||||
}
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
|
58
tag.c
58
tag.c
@ -1,6 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
@ -12,7 +12,7 @@
|
||||
typedef struct {
|
||||
const char *prop;
|
||||
const char *tags;
|
||||
Bool isversatile;
|
||||
Bool isfloating;
|
||||
} Rule;
|
||||
|
||||
typedef struct {
|
||||
@ -83,7 +83,7 @@ settags(Client *c, Client *trans) {
|
||||
ch.res_name ? ch.res_name : "", c->name);
|
||||
for(i = 0; i < nrules; i++)
|
||||
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
|
||||
c->isversatile = rule[i].isversatile;
|
||||
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;
|
||||
@ -102,49 +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] = (arg->i == -1) ? True : False;
|
||||
if(arg->i >= 0 && arg->i < ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
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;
|
||||
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(Arg *arg) {
|
||||
unsigned int i;
|
||||
toggleview(const char *arg) {
|
||||
int i, j;
|
||||
|
||||
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 */
|
||||
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(Arg *arg) {
|
||||
unsigned int i;
|
||||
view(const char *arg) {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = (arg->i == -1) ? True : False;
|
||||
if(arg->i >= 0 && arg->i < ntags)
|
||||
seltag[arg->i] = True;
|
||||
seltag[i] = arg == NULL;
|
||||
i = arg ? atoi(arg) : 0;
|
||||
if(i >= 0 && i < ntags)
|
||||
seltag[i] = True;
|
||||
lt->arrange();
|
||||
}
|
||||
|
14
util.c
14
util.c
@ -1,6 +1,6 @@
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
* See LICENSE file for license details. */
|
||||
#include "dwm.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -30,12 +30,12 @@ eprint(const char *errstr, ...) {
|
||||
}
|
||||
|
||||
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. */
|
||||
@ -44,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);
|
||||
|
Reference in New Issue
Block a user