Compare commits
83 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
4606d218c3 | |||
d37d0f24e6 | |||
321e8d51ed | |||
78f4b51757 | |||
7d168a2621 | |||
931e712eac | |||
4ec04209e0 | |||
82ddba88a2 | |||
52a8cc8d46 | |||
d175df8aa3 | |||
b003a35fde | |||
df1a0f9445 | |||
5b07b85838 | |||
f320cd203b | |||
f78c16f8c6 | |||
0c5f47e720 | |||
4b5b3d90af | |||
2cce4b95cd | |||
8e6eb52196 | |||
04b633ddf3 | |||
b76561a212 | |||
51c7589c87 | |||
99785382ae | |||
dc1690ce0f | |||
b6614261ea | |||
91e569ca37 | |||
0f395c1b11 | |||
2b13e7466f | |||
0982e47408 | |||
b93ebcf42f | |||
a08d83ba62 | |||
2b7c275ce8 | |||
040d0f48a0 | |||
724f35a664 | |||
6f3872edbd | |||
87324e680c | |||
c2b908f603 | |||
d7734f996f | |||
8b68890650 | |||
b60406cb9b | |||
ce9a9934ec | |||
720b2abe17 | |||
5983c00b95 | |||
6651dd7fd9 | |||
acdea31916 | |||
10885d349a | |||
1c1d09f3e9 | |||
0384faeee5 | |||
6cca3999c8 |
7
.hgtags
7
.hgtags
@ -16,3 +16,10 @@ f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
|||||||
ad3fa2d185426c51fd5deceae809770363f8d33c 1.6
|
ad3fa2d185426c51fd5deceae809770363f8d33c 1.6
|
||||||
4dbdb61c8b8ce21dee5c7050a6b103855964ed20 1.7
|
4dbdb61c8b8ce21dee5c7050a6b103855964ed20 1.7
|
||||||
d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
||||||
|
c71952fa3c7ca848ec38a6923b5c6d0e18fff431 1.8
|
||||||
|
a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||||
|
12deea36603da407e3f32640048846a3bd74a9ec 2.0
|
||||||
|
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||||
|
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
|
||||||
|
719b37b37b0df829d7cf017ac70e353088fe5849 2.3
|
||||||
|
32b246925086910d63147483160281a91a47479f 2.4
|
||||||
|
34
client.c
34
client.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -156,7 +155,6 @@ gravitate(Client *c, Bool invert) {
|
|||||||
dy = -(c->h);
|
dy = -(c->h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c->grav) {
|
switch (c->grav) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -177,7 +175,6 @@ gravitate(Client *c, Bool invert) {
|
|||||||
dx = -(c->w + c->border);
|
dx = -(c->w + c->border);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(invert) {
|
if(invert) {
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
@ -205,15 +202,13 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
c = emallocz(sizeof(Client));
|
c = emallocz(sizeof(Client));
|
||||||
c->tags = emallocz(ntags * sizeof(Bool));
|
c->tags = emallocz(ntags * sizeof(Bool));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
|
c->border = 0;
|
||||||
c->x = c->tx = wa->x;
|
c->x = c->tx = wa->x;
|
||||||
c->y = c->ty = wa->y;
|
c->y = c->ty = wa->y;
|
||||||
c->w = c->tw = wa->width;
|
c->w = c->tw = wa->width;
|
||||||
c->h = wa->height;
|
c->h = wa->height;
|
||||||
c->th = bh;
|
c->th = bh;
|
||||||
|
|
||||||
c->border = 0;
|
|
||||||
updatesize(c);
|
updatesize(c);
|
||||||
|
|
||||||
if(c->x + c->w + 2 * BORDERPX > sw)
|
if(c->x + c->w + 2 * BORDERPX > sw)
|
||||||
c->x = sw - c->w - 2 * BORDERPX;
|
c->x = sw - c->w - 2 * BORDERPX;
|
||||||
if(c->x < sx)
|
if(c->x < sx)
|
||||||
@ -222,7 +217,6 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
c->y = sh - c->h - 2 * BORDERPX;
|
c->y = sh - c->h - 2 * BORDERPX;
|
||||||
if(c->h != sh && c->y < bh)
|
if(c->h != sh && c->y < bh)
|
||||||
c->y = bh;
|
c->y = bh;
|
||||||
|
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||||
@ -230,33 +224,27 @@ manage(Window w, XWindowAttributes *wa) {
|
|||||||
twa.override_redirect = 1;
|
twa.override_redirect = 1;
|
||||||
twa.background_pixmap = ParentRelative;
|
twa.background_pixmap = ParentRelative;
|
||||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||||
|
|
||||||
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
grabbuttons(c, False);
|
grabbuttons(c, False);
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
settags(c, getclient(trans));
|
settags(c, getclient(trans));
|
||||||
if(!c->isfloat)
|
if(!c->isfloat)
|
||||||
c->isfloat = trans
|
c->isfloat = trans || c->isfixed;
|
||||||
|| (c->maxw && c->minw &&
|
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
|
||||||
resizetitle(c);
|
resizetitle(c);
|
||||||
|
|
||||||
if(clients)
|
if(clients)
|
||||||
clients->prev = c;
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
c->snext = stack;
|
c->snext = stack;
|
||||||
stack = clients = c;
|
stack = clients = c;
|
||||||
|
|
||||||
ban(c);
|
ban(c);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -283,7 +271,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
|||||||
c->x = right - c->w;
|
c->x = right - c->w;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
if(sticky == BotLeft || sticky == BotRight)
|
||||||
c->y = bottom - c->h;
|
c->y = bottom - c->h;
|
||||||
|
|
||||||
/* offscreen appearance fixes */
|
/* offscreen appearance fixes */
|
||||||
if(c->x + c->w < sx)
|
if(c->x + c->w < sx)
|
||||||
c->x = sx;
|
c->x = sx;
|
||||||
@ -293,7 +280,6 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
|||||||
c->x = sw - c->w;
|
c->x = sw - c->w;
|
||||||
if(c->y > sh)
|
if(c->y > sh)
|
||||||
c->y = sh - c->h;
|
c->y = sh - c->h;
|
||||||
|
|
||||||
resizetitle(c);
|
resizetitle(c);
|
||||||
wc.x = c->x;
|
wc.x = c->x;
|
||||||
wc.y = c->y;
|
wc.y = c->y;
|
||||||
@ -353,6 +339,8 @@ updatesize(Client *c) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->minw = c->minh = 0;
|
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)
|
if(c->flags & PWinGravity)
|
||||||
c->grav = size.win_gravity;
|
c->grav = size.win_gravity;
|
||||||
else
|
else
|
||||||
@ -373,12 +361,12 @@ updatetitle(Client *c) {
|
|||||||
if(!name.nitems)
|
if(!name.nitems)
|
||||||
return;
|
return;
|
||||||
if(name.encoding == XA_STRING)
|
if(name.encoding == XA_STRING)
|
||||||
strncpy(c->name, (char *)name.value, sizeof(c->name));
|
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||||
else {
|
else {
|
||||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
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);
|
XFreeStringList(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,22 +380,18 @@ unmanage(Client *c) {
|
|||||||
/* The server grab construct avoids race conditions. */
|
/* The server grab construct avoids race conditions. */
|
||||||
XGrabServer(dpy);
|
XGrabServer(dpy);
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
|
|
||||||
detach(c);
|
detach(c);
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
if(sel == c) {
|
if(sel == c) {
|
||||||
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
||||||
focus(nc);
|
focus(nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
XDestroyWindow(dpy, c->twin);
|
XDestroyWindow(dpy, c->twin);
|
||||||
|
|
||||||
free(c->tags);
|
free(c->tags);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
46
config.arg.h
46
config.arg.h
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,37 +7,35 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
|||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "><>"
|
#define FLOATSYMBOL "><>"
|
||||||
#define STACKPOS StackRight /* StackLeft */
|
#define TILESYMBOL "[]="
|
||||||
#define BSTACKSYMBOL "==="
|
|
||||||
#define VSTACKSYMBOL "[]="
|
|
||||||
|
|
||||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*"
|
||||||
#define NORMBGCOLOR "#333333"
|
#define NORMBGCOLOR "#333333"
|
||||||
#define NORMFGCOLOR "#dddddd"
|
#define NORMFGCOLOR "#cccccc"
|
||||||
#define SELBGCOLOR "#333366"
|
#define SELBGCOLOR "#336699"
|
||||||
#define SELFGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#dddddd"
|
||||||
#define STATUSBGCOLOR "#222222"
|
#define STATUSBGCOLOR "#222222"
|
||||||
#define STATUSFGCOLOR "#9999cc"
|
#define STATUSFGCOLOR "#99ccff"
|
||||||
|
|
||||||
#define MASTER 60 /* percent */
|
#define MASTER 600 /* per thousand */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
|
#define SNAP 40 /* pixel */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function argument */ \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||||
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||||
{ MODKEY, XK_p, spawn, \
|
{ MODKEY, XK_p, spawn, \
|
||||||
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
|
||||||
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; done " \
|
" | dmenu -font '"FONT"' -normbg '"NORMBGCOLOR"' -normfg '"NORMFGCOLOR"' " \
|
||||||
"| sort -u | dmenu -font '"FONT"' -normbg '"NORMBGCOLOR"' -normfg '"NORMFGCOLOR"' " \
|
|
||||||
"-selbg '"SELBGCOLOR"' -selfg '"SELFGCOLOR"')\" && exec $exe" } }, \
|
"-selbg '"SELBGCOLOR"' -selfg '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_b, togglestackpos, { 0 } }, \
|
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||||
{ MODKEY, XK_g, resizecol, { .i = 1 } }, \
|
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||||
{ MODKEY, XK_s, resizecol, { .i = -1 } }, \
|
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
@ -49,7 +46,8 @@ static Key key[] = { \
|
|||||||
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||||
|
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
@ -64,8 +62,8 @@ static Key key[] = { \
|
|||||||
#define RULES \
|
#define RULES \
|
||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "net", False}, \
|
{ "Firefox.*", "net", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True }, \
|
||||||
{ "MPlayer.*", NULL, True}, \
|
{ "MPlayer.*", NULL, True }, \
|
||||||
{ "Acroread.*", NULL, True}, \
|
{ "Acroread.*", NULL, True }, \
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,9 +7,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
|||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "><>"
|
#define FLOATSYMBOL "><>"
|
||||||
#define STACKPOS StackRight /* StackLeft */
|
#define TILESYMBOL "[]="
|
||||||
#define BSTACKSYMBOL "==="
|
|
||||||
#define VSTACKSYMBOL "[]="
|
|
||||||
|
|
||||||
#define FONT "fixed"
|
#define FONT "fixed"
|
||||||
#define NORMBGCOLOR "#333366"
|
#define NORMBGCOLOR "#333366"
|
||||||
@ -20,19 +17,20 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
|||||||
#define STATUSBGCOLOR "#dddddd"
|
#define STATUSBGCOLOR "#dddddd"
|
||||||
#define STATUSFGCOLOR "#222222"
|
#define STATUSFGCOLOR "#222222"
|
||||||
|
|
||||||
#define MASTER 60 /* percent */
|
#define MASTER 600 /* per thousand */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
|
#define SNAP 20 /* pixel */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function argument */ \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
||||||
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_b, togglestackpos, { 0 } }, \
|
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||||
{ MODKEY, XK_g, resizecol, { .i = 1 } }, \
|
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||||
{ MODKEY, XK_s, resizecol, { .i = -1 } }, \
|
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
@ -45,7 +43,8 @@ static Key key[] = { \
|
|||||||
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||||
|
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
@ -65,5 +64,5 @@ static Key key[] = { \
|
|||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "2", False }, \
|
{ "Firefox.*", "2", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True }, \
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 1.8
|
VERSION = 2.5
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
72
draw.c
72
draw.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -9,6 +8,16 @@
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
isoccupied(unsigned int t)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
for(c = clients; c; c = c->next)
|
||||||
|
if(c->tags[t])
|
||||||
|
return True;
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
textnw(const char *text, unsigned int len) {
|
textnw(const char *text, unsigned int len) {
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
@ -21,30 +30,27 @@ textnw(const char *text, unsigned int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool emptysquare) {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
unsigned int len, olen;
|
unsigned int len, olen;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||||
|
XPoint pt[5];
|
||||||
|
|
||||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
w = 0;
|
w = 0;
|
||||||
olen = len = strlen(text);
|
olen = len = strlen(text);
|
||||||
if(len >= sizeof(buf))
|
if(len >= sizeof buf)
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof buf - 1;
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
|
|
||||||
h = dc.font.ascent + dc.font.descent;
|
h = dc.font.ascent + dc.font.descent;
|
||||||
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
|
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
|
||||||
x = dc.x + (h / 2);
|
x = dc.x + (h / 2);
|
||||||
|
|
||||||
/* shorten text if necessary */
|
/* shorten text if necessary */
|
||||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||||
buf[--len] = 0;
|
buf[--len] = 0;
|
||||||
@ -56,7 +62,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
|||||||
if(len > 3)
|
if(len > 3)
|
||||||
buf[len - 3] = '.';
|
buf[len - 3] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w > dc.w)
|
if(w > dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
gcv.foreground = col[ColFG];
|
gcv.foreground = col[ColFG];
|
||||||
@ -69,12 +74,26 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
|||||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||||
}
|
}
|
||||||
if(highlight) {
|
x = (h + 2) / 4;
|
||||||
r.x = dc.x + 2;
|
if(filledsquare) {
|
||||||
r.y = dc.y + 2;
|
r.x = dc.x + 1;
|
||||||
r.width = r.height = (h + 2) / 4;
|
r.y = dc.y + 1;
|
||||||
|
r.width = r.height = x + 1;
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
}
|
}
|
||||||
|
else if(emptysquare) {
|
||||||
|
pt[0].x = dc.x + 1;
|
||||||
|
pt[0].y = dc.y + 1;
|
||||||
|
pt[1].x = x;
|
||||||
|
pt[1].y = 0;
|
||||||
|
pt[2].x = 0;
|
||||||
|
pt[2].y = x;
|
||||||
|
pt[3].x = -x;
|
||||||
|
pt[3].y = 0;
|
||||||
|
pt[4].x = 0;
|
||||||
|
pt[4].y = -x;
|
||||||
|
XDrawLines(dpy, dc.drawable, dc.gc, pt, 5, CoordModePrevious);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
@ -93,36 +112,27 @@ drawstatus(void) {
|
|||||||
int i, x;
|
int i, x;
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++) {
|
for(i = 0; i < ntags; i++) {
|
||||||
dc.w = textw(tags[i]);
|
dc.w = textw(tags[i]);
|
||||||
if(seltag[i])
|
if(seltag[i])
|
||||||
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i));
|
||||||
else
|
else
|
||||||
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i));
|
||||||
dc.x += dc.w;
|
dc.x += dc.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.w = bmw;
|
dc.w = bmw;
|
||||||
drawtext(arrange == dofloat ?
|
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False, False);
|
||||||
FLOATSYMBOL : stackpos == StackBottom ?
|
|
||||||
BSTACKSYMBOL : VSTACKSYMBOL, dc.status, False);
|
|
||||||
|
|
||||||
x = dc.x + dc.w;
|
x = dc.x + dc.w;
|
||||||
dc.w = textw(stext);
|
dc.w = textw(stext);
|
||||||
dc.x = bx + bw - dc.w;
|
dc.x = bw - dc.w;
|
||||||
if(dc.x < x) {
|
if(dc.x < x) {
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
dc.w = bw - x;
|
dc.w = bw - x;
|
||||||
}
|
}
|
||||||
drawtext(stext, dc.status, False);
|
drawtext(stext, dc.status, False, False);
|
||||||
|
|
||||||
if((dc.w = dc.x - x) > bh) {
|
if((dc.w = dc.x - x) > bh) {
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
if(sel)
|
drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False);
|
||||||
drawtext(sel->name, dc.sel, False);
|
|
||||||
else
|
|
||||||
drawtext(NULL, dc.norm, False);
|
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -136,12 +146,11 @@ drawtitle(Client *c) {
|
|||||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
dc.w = c->tw;
|
dc.w = c->tw;
|
||||||
drawtext(c->name, dc.norm, False);
|
drawtext(c->name, dc.norm, False,False);
|
||||||
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
@ -179,7 +188,6 @@ setfont(const char *fontstr) {
|
|||||||
XFontSetExtents *font_extents;
|
XFontSetExtents *font_extents;
|
||||||
XFontStruct **xfonts;
|
XFontStruct **xfonts;
|
||||||
char **font_names;
|
char **font_names;
|
||||||
|
|
||||||
dc.font.ascent = dc.font.descent = 0;
|
dc.font.ascent = dc.font.descent = 0;
|
||||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||||
|
22
dwm.1
22
dwm.1
@ -20,8 +20,10 @@ tags. Selecting certain tags displays all windows with these tags.
|
|||||||
.P
|
.P
|
||||||
dwm contains a small status bar which displays all available tags, the mode,
|
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
|
the title of the focused window, and the text read from standard input. The
|
||||||
selected tags are highlighted with a different color, the tags of the focused
|
selected tags are indicated with a different color. The tags of the focused
|
||||||
window are highlighted with a small point.
|
window are indicated with a filled square in the top left corner. The tags
|
||||||
|
which are applied to one or more clients are indicated with an empty square in
|
||||||
|
the top left corner.
|
||||||
.P
|
.P
|
||||||
dwm draws a 1-pixel border around windows to indicate the focus state.
|
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.
|
Unfocused windows contain a small bar in front of them displaying their title.
|
||||||
@ -40,8 +42,7 @@ click on a tag label to display all windows with that tag, click on the mode
|
|||||||
label toggles between tiling and floating mode.
|
label toggles between tiling and floating mode.
|
||||||
.TP
|
.TP
|
||||||
.B Button3
|
.B Button3
|
||||||
click on a tag label adds/removes all windows with that tag to/from the view,
|
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||||
click on the mode label toggles the stack position (tiling mode).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
click on a tag label applies that tag to the focused window.
|
click on a tag label applies that tag to the focused window.
|
||||||
@ -63,20 +64,20 @@ Focus previous window.
|
|||||||
.B Mod1-Return
|
.B Mod1-Return
|
||||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-b
|
|
||||||
Toggle stack position (tiling mode only).
|
|
||||||
.TP
|
|
||||||
.B Mod1-g
|
.B Mod1-g
|
||||||
Grow current area (tiling mode only).
|
Grow master area (tiling mode only).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-s
|
.B Mod1-s
|
||||||
Shrink current area (tiling mode only).
|
Shrink master area (tiling mode only).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-[1..n]
|
.B Mod1-Shift-[1..n]
|
||||||
Apply
|
Apply
|
||||||
.RB nth
|
.RB nth
|
||||||
tag to current window.
|
tag to current window.
|
||||||
.TP
|
.TP
|
||||||
|
.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
|
Add/remove
|
||||||
.B nth
|
.B nth
|
||||||
@ -88,6 +89,9 @@ Close focused window.
|
|||||||
.B Mod1-space
|
.B Mod1-space
|
||||||
Toggle between tiling and floating mode (affects all windows).
|
Toggle between tiling and floating mode (affects all windows).
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1-Shift-space
|
||||||
|
Toggle focused window between floating and non-floating state (tiling mode only).
|
||||||
|
.TP
|
||||||
.B Mod1-[1..n]
|
.B Mod1-[1..n]
|
||||||
View all windows with
|
View all windows with
|
||||||
.BR nth
|
.BR nth
|
||||||
|
25
dwm.h
25
dwm.h
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*
|
*
|
||||||
* dynamic window manager is designed like any other X client as well. It is
|
* dynamic window manager is designed like any other X client as well. It is
|
||||||
@ -37,7 +36,6 @@
|
|||||||
|
|
||||||
/* mask shorthands, used in event.c and client.c */
|
/* mask shorthands, used in event.c and client.c */
|
||||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
|
||||||
/* other stuff used in different places */
|
/* other stuff used in different places */
|
||||||
#define BORDERPX 1
|
#define BORDERPX 1
|
||||||
#define PROTODELWIN 1
|
#define PROTODELWIN 1
|
||||||
@ -47,10 +45,6 @@ enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
|
|||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
enum { ColFG, ColBG, ColLast }; /* color */
|
enum { ColFG, ColBG, ColLast }; /* color */
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
StackLeft, StackBottom, StackRight
|
|
||||||
} StackPos; /* stack position*/
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TopLeft, TopRight, BotLeft, BotRight
|
TopLeft, TopRight, BotLeft, BotRight
|
||||||
} Corner; /* window corners */
|
} Corner; /* window corners */
|
||||||
@ -88,8 +82,8 @@ struct Client {
|
|||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
int grav;
|
int grav;
|
||||||
long flags;
|
long flags;
|
||||||
unsigned int border, weight;
|
unsigned int border;
|
||||||
Bool isfloat, ismax;
|
Bool isfloat, isfixed, ismax;
|
||||||
Bool *tags;
|
Bool *tags;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *prev;
|
Client *prev;
|
||||||
@ -102,16 +96,16 @@ extern const char *tags[]; /* all tags */
|
|||||||
extern char stext[1024]; /* status text */
|
extern char stext[1024]; /* status text */
|
||||||
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
||||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
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 unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
|
||||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||||
extern void (*arrange)(Arg *); /* arrange function, indicates mode */
|
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||||
extern Bool running, issel, *seltag; /* seltag is array of Bool */
|
extern Bool running, issel, *seltag; /* seltag is array of Bool */
|
||||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc; /* global draw context */
|
extern DC dc; /* global draw context */
|
||||||
extern Display *dpy;
|
extern Display *dpy;
|
||||||
extern StackPos stackpos;
|
|
||||||
extern Window root, barwin;
|
extern Window root, barwin;
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
@ -163,16 +157,15 @@ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
|
|||||||
|
|
||||||
/* view.c */
|
/* view.c */
|
||||||
extern void detach(Client *c); /* detaches c from global client list */
|
extern void detach(Client *c); /* detaches c from global client list */
|
||||||
extern void dofloat(Arg *arg); /* arranges all windows floating, arg is ignored */
|
extern void dofloat(void); /* arranges all windows floating */
|
||||||
extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
|
extern void dotile(void); /* arranges all windows tiled */
|
||||||
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
|
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 focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
|
||||||
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
||||||
extern void resizecol(Arg *arg); /* resizes the master percent with arg's index value */
|
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 restack(void); /* restores z layers of all clients */
|
||||||
extern void togglestackpos(Arg *arg); /* toggles stack position */
|
extern void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */
|
||||||
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
|
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 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 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 */
|
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
|
||||||
|
34
event.c
34
event.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -19,6 +18,7 @@ typedef struct {
|
|||||||
KEYS
|
KEYS
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||||
|
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
movemouse(Client *c) {
|
movemouse(Client *c) {
|
||||||
@ -48,6 +48,14 @@ movemouse(Client *c) {
|
|||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
c->x = ocx + (ev.xmotion.x - x1);
|
c->x = ocx + (ev.xmotion.x - x1);
|
||||||
c->y = ocy + (ev.xmotion.y - y1);
|
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);
|
resize(c, False, TopLeft);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -123,12 +131,8 @@ buttonpress(XEvent *e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ev->x < x + bmw) {
|
if((ev->x < x + bmw) && (ev->button == Button1))
|
||||||
if(ev->button == Button1)
|
|
||||||
togglemode(NULL);
|
togglemode(NULL);
|
||||||
else if(ev->button == Button3)
|
|
||||||
togglestackpos(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if((c = getclient(ev->window))) {
|
else if((c = getclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
@ -140,7 +144,8 @@ buttonpress(XEvent *e) {
|
|||||||
}
|
}
|
||||||
else if(ev->button == Button2)
|
else if(ev->button == Button2)
|
||||||
zoom(NULL);
|
zoom(NULL);
|
||||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
|
||||||
|
!c->isfixed) {
|
||||||
restack();
|
restack();
|
||||||
resizemouse(c);
|
resizemouse(c);
|
||||||
}
|
}
|
||||||
@ -184,7 +189,7 @@ configurerequest(XEvent *e) {
|
|||||||
ban(c);
|
ban(c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wc.x = ev->x;
|
wc.x = ev->x;
|
||||||
@ -215,7 +220,6 @@ enternotify(XEvent *e) {
|
|||||||
|
|
||||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
|
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
else if(ev->window == root) {
|
else if(ev->window == root) {
|
||||||
@ -240,7 +244,7 @@ expose(XEvent *e) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
keypress(XEvent *e) {
|
keypress(XEvent *e) {
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof key / sizeof key[0];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
XKeyEvent *ev = &e->xkey;
|
XKeyEvent *ev = &e->xkey;
|
||||||
@ -252,7 +256,6 @@ keypress(XEvent *e) {
|
|||||||
{
|
{
|
||||||
if(key[i].func)
|
if(key[i].func)
|
||||||
key[i].func(&key[i].arg);
|
key[i].func(&key[i].arg);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,13 +286,11 @@ maprequest(XEvent *e) {
|
|||||||
|
|
||||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(wa.override_redirect) {
|
if(wa.override_redirect) {
|
||||||
XSelectInput(dpy, ev->window,
|
XSelectInput(dpy, ev->window,
|
||||||
(StructureNotifyMask | PropertyChangeMask));
|
(StructureNotifyMask | PropertyChangeMask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getclient(ev->window))
|
if(!getclient(ev->window))
|
||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
}
|
}
|
||||||
@ -302,7 +303,6 @@ propertynotify(XEvent *e) {
|
|||||||
|
|
||||||
if(ev->state == PropertyDelete)
|
if(ev->state == PropertyDelete)
|
||||||
return; /* ignore */
|
return; /* ignore */
|
||||||
|
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
if(ev->atom == wmatom[WMProtocols]) {
|
if(ev->atom == wmatom[WMProtocols]) {
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
@ -313,7 +313,7 @@ propertynotify(XEvent *e) {
|
|||||||
case XA_WM_TRANSIENT_FOR:
|
case XA_WM_TRANSIENT_FOR:
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
||||||
arrange(NULL);
|
arrange();
|
||||||
break;
|
break;
|
||||||
case XA_WM_NORMAL_HINTS:
|
case XA_WM_NORMAL_HINTS:
|
||||||
updatesize(c);
|
updatesize(c);
|
||||||
@ -354,7 +354,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
|||||||
|
|
||||||
void
|
void
|
||||||
grabkeys(void) {
|
grabkeys(void) {
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof key / sizeof key[0];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
|
|
||||||
|
80
main.c
80
main.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,7 +18,7 @@
|
|||||||
|
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
Bool *seltag;
|
Bool *seltag;
|
||||||
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh;
|
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||||
unsigned int master, ntags, numlockmask;
|
unsigned int master, ntags, numlockmask;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
@ -93,12 +92,11 @@ setup(void) {
|
|||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||||
|
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||||
|
/* init modifier map */
|
||||||
modmap = XGetModifierMapping(dpy);
|
modmap = XGetModifierMapping(dpy);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||||
@ -107,19 +105,16 @@ setup(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(modmap);
|
XFree(modmap);
|
||||||
|
/* select for events */
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
| EnterWindowMask | LeaveWindowMask;
|
| EnterWindowMask | LeaveWindowMask;
|
||||||
wa.cursor = cursor[CurNormal];
|
wa.cursor = cursor[CurNormal];
|
||||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||||
|
|
||||||
grabkeys();
|
grabkeys();
|
||||||
initrregs();
|
initrregs();
|
||||||
|
|
||||||
for(ntags = 0; tags[ntags]; ntags++);
|
for(ntags = 0; tags[ntags]; ntags++);
|
||||||
seltag = emallocz(sizeof(Bool) * ntags);
|
seltag = emallocz(sizeof(Bool) * ntags);
|
||||||
seltag[0] = True;
|
seltag[0] = True;
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||||
@ -128,17 +123,15 @@ setup(void) {
|
|||||||
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||||
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||||
setfont(FONT);
|
setfont(FONT);
|
||||||
|
/* geometry */
|
||||||
bmw = textw(VSTACKSYMBOL) > textw(BSTACKSYMBOL) ?
|
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||||
textw(VSTACKSYMBOL) : textw(BSTACKSYMBOL);
|
|
||||||
bmw = bmw > textw(FLOATSYMBOL) ?
|
|
||||||
bmw : textw(FLOATSYMBOL);
|
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
sh = DisplayHeight(dpy, screen);
|
sh = DisplayHeight(dpy, screen);
|
||||||
master = MASTER;
|
master = MASTER;
|
||||||
|
/* bar */
|
||||||
bx = by = 0;
|
bx = sx;
|
||||||
|
by = sy;
|
||||||
bw = sw;
|
bw = sw;
|
||||||
dc.h = bh = dc.font.height + 2;
|
dc.h = bh = dc.font.height + 2;
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
@ -149,13 +142,18 @@ setup(void) {
|
|||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||||
XMapRaised(dpy, barwin);
|
XMapRaised(dpy, barwin);
|
||||||
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
/* windowarea */
|
||||||
|
wax = sx;
|
||||||
|
way = sy + bh;
|
||||||
|
wah = sh - bh;
|
||||||
|
waw = sw;
|
||||||
|
/* pixmap for everything */
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
/* multihead support */
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
strcpy(stext, "dwm-"VERSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -207,8 +205,7 @@ quit(Arg *arg) {
|
|||||||
readin = running = False;
|
readin = running = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
* There's no way to check accesses to destroyed windows, thus those cases are
|
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which may call exit.
|
* default error handler, which may call exit.
|
||||||
*/
|
*/
|
||||||
@ -230,6 +227,7 @@ xerror(Display *dpy, XErrorEvent *ee) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
|
char *p;
|
||||||
int r, xfd;
|
int r, xfd;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
|
|
||||||
@ -239,21 +237,17 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
else if(argc != 1)
|
else if(argc != 1)
|
||||||
eprint("usage: dwm [-v]\n");
|
eprint("usage: dwm [-v]\n");
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
dpy = XOpenDisplay(0);
|
||||||
if(!dpy)
|
if(!dpy)
|
||||||
eprint("dwm: cannot open display\n");
|
eprint("dwm: cannot open display\n");
|
||||||
|
|
||||||
xfd = ConnectionNumber(dpy);
|
xfd = ConnectionNumber(dpy);
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
|
|
||||||
otherwm = False;
|
otherwm = False;
|
||||||
XSetErrorHandler(xerrorstart);
|
XSetErrorHandler(xerrorstart);
|
||||||
/* this causes an error if some other window manager is running */
|
/* this causes an error if some other window manager is running */
|
||||||
XSelectInput(dpy, root, SubstructureRedirectMask);
|
XSelectInput(dpy, root, SubstructureRedirectMask);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
if(otherwm)
|
if(otherwm)
|
||||||
eprint("dwm: another window manager is already running\n");
|
eprint("dwm: another window manager is already running\n");
|
||||||
|
|
||||||
@ -261,7 +255,6 @@ main(int argc, char *argv[]) {
|
|||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(NULL);
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
xerrorxlib = XSetErrorHandler(xerror);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
drawstatus();
|
drawstatus();
|
||||||
scan();
|
scan();
|
||||||
@ -275,25 +268,34 @@ main(int argc, char *argv[]) {
|
|||||||
if(readin)
|
if(readin)
|
||||||
FD_SET(STDIN_FILENO, &rd);
|
FD_SET(STDIN_FILENO, &rd);
|
||||||
FD_SET(xfd, &rd);
|
FD_SET(xfd, &rd);
|
||||||
r = select(xfd + 1, &rd, NULL, NULL, NULL);
|
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
|
||||||
if((r == -1) && (errno == EINTR))
|
if(errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
if(r > 0) {
|
eprint("select failed\n");
|
||||||
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
}
|
||||||
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
||||||
if(readin)
|
switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
|
||||||
stext[strlen(stext) - 1] = 0;
|
case -1:
|
||||||
else
|
strncpy(stext, strerror(errno), sizeof stext - 1);
|
||||||
strcpy(stext, "broken pipe");
|
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 + strlen(stext) - 1; p >= stext && *p != '\n'; --p);
|
||||||
|
if(p > stext)
|
||||||
|
strncpy(stext, p + 1, sizeof stext);
|
||||||
|
}
|
||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
}
|
if(FD_ISSET(xfd, &rd))
|
||||||
else if(r < 0)
|
|
||||||
eprint("select failed\n");
|
|
||||||
procevent();
|
procevent();
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
25
tag.c
25
tag.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -51,20 +50,19 @@ initrregs(void) {
|
|||||||
|
|
||||||
if(rreg)
|
if(rreg)
|
||||||
return;
|
return;
|
||||||
len = sizeof(rule) / sizeof(rule[0]);
|
len = sizeof rule / sizeof rule[0];
|
||||||
rreg = emallocz(len * sizeof(RReg));
|
rreg = emallocz(len * sizeof(RReg));
|
||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
if(rule[i].clpattern) {
|
if(rule[i].clpattern) {
|
||||||
reg = emallocz(sizeof(regex_t));
|
reg = emallocz(sizeof(regex_t));
|
||||||
if(regcomp(reg, rule[i].clpattern, 0))
|
if(regcomp(reg, rule[i].clpattern, REG_EXTENDED))
|
||||||
free(reg);
|
free(reg);
|
||||||
else
|
else
|
||||||
rreg[i].clregex = reg;
|
rreg[i].clregex = reg;
|
||||||
}
|
}
|
||||||
if(rule[i].tpattern) {
|
if(rule[i].tpattern) {
|
||||||
reg = emallocz(sizeof(regex_t));
|
reg = emallocz(sizeof(regex_t));
|
||||||
if(regcomp(reg, rule[i].tpattern, 0))
|
if(regcomp(reg, rule[i].tpattern, REG_EXTENDED))
|
||||||
free(reg);
|
free(reg);
|
||||||
else
|
else
|
||||||
rreg[i].tregex = reg;
|
rreg[i].tregex = reg;
|
||||||
@ -85,10 +83,10 @@ settags(Client *c, Client *trans) {
|
|||||||
c->tags[i] = trans->tags[i];
|
c->tags[i] = trans->tags[i];
|
||||||
}
|
}
|
||||||
else if(XGetClassHint(dpy, c->win, &ch)) {
|
else if(XGetClassHint(dpy, c->win, &ch)) {
|
||||||
snprintf(prop, sizeof(prop), "%s:%s:%s",
|
snprintf(prop, sizeof prop, "%s:%s:%s",
|
||||||
ch.res_class ? ch.res_class : "",
|
ch.res_class ? ch.res_class : "",
|
||||||
ch.res_name ? ch.res_name : "", c->name);
|
ch.res_name ? ch.res_name : "", c->name);
|
||||||
for(i = 0; !matched && i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
|
if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
|
||||||
c->isfloat = rule[i].isfloat;
|
c->isfloat = rule[i].isfloat;
|
||||||
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
||||||
@ -106,7 +104,6 @@ settags(Client *c, Client *trans) {
|
|||||||
if(!matched)
|
if(!matched)
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
c->tags[i] = seltag[i];
|
c->tags[i] = seltag[i];
|
||||||
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -115,12 +112,10 @@ tag(Arg *arg) {
|
|||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
sel->tags[i] = False;
|
sel->tags[i] = (arg->i == -1) ? True : False;
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
sel->weight = arg->i;
|
arrange();
|
||||||
arrange(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -129,11 +124,9 @@ toggletag(Arg *arg) {
|
|||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sel->tags[arg->i] = !sel->tags[arg->i];
|
sel->tags[arg->i] = !sel->tags[arg->i];
|
||||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
sel->weight = (i == ntags) ? arg->i : i;
|
arrange();
|
||||||
arrange(NULL);
|
|
||||||
}
|
}
|
||||||
|
5
util.c
5
util.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -33,6 +32,7 @@ eprint(const char *errstr, ...) {
|
|||||||
void *
|
void *
|
||||||
erealloc(void *ptr, unsigned int size) {
|
erealloc(void *ptr, unsigned int size) {
|
||||||
void *res = realloc(ptr, size);
|
void *res = realloc(ptr, size);
|
||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||||
return res;
|
return res;
|
||||||
@ -44,7 +44,6 @@ spawn(Arg *arg) {
|
|||||||
|
|
||||||
if(!shell && !(shell = getenv("SHELL")))
|
if(!shell && !(shell = getenv("SHELL")))
|
||||||
shell = "/bin/sh";
|
shell = "/bin/sh";
|
||||||
|
|
||||||
if(!arg->cmd)
|
if(!arg->cmd)
|
||||||
return;
|
return;
|
||||||
/* The double-fork construct avoids zombie processes and keeps the code
|
/* The double-fork construct avoids zombie processes and keeps the code
|
||||||
|
208
view.c
208
view.c
@ -1,23 +1,10 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static Client *
|
|
||||||
minclient(void) {
|
|
||||||
Client *c, *min;
|
|
||||||
|
|
||||||
if((clients && clients->isfloat) || arrange == dofloat)
|
|
||||||
return clients; /* don't touch floating order */
|
|
||||||
for(min = c = clients; c; c = c->next)
|
|
||||||
if(c->weight < min->weight)
|
|
||||||
min = c;
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Client *
|
static Client *
|
||||||
nexttiled(Client *c) {
|
nexttiled(Client *c) {
|
||||||
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||||
@ -25,32 +12,17 @@ nexttiled(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reorder(void) {
|
togglemax(Client *c) {
|
||||||
Client *c, *newclients, *tail;
|
|
||||||
|
|
||||||
newclients = tail = NULL;
|
|
||||||
while((c = minclient())) {
|
|
||||||
detach(c);
|
|
||||||
if(tail) {
|
|
||||||
c->prev = tail;
|
|
||||||
tail->next = c;
|
|
||||||
tail = c;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tail = newclients = c;
|
|
||||||
}
|
|
||||||
clients = newclients;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
togglemax(Client *c)
|
|
||||||
{
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
|
if(c->isfixed)
|
||||||
|
return;
|
||||||
|
|
||||||
if((c->ismax = !c->ismax)) {
|
if((c->ismax = !c->ismax)) {
|
||||||
c->rx = c->x; c->x = sx;
|
c->rx = c->x; c->x = wax;
|
||||||
c->ry = c->y; c->y = bh;
|
c->ry = c->y; c->y = way;
|
||||||
c->rw = c->w; c->w = sw - 2 * BORDERPX;
|
c->rw = c->w; c->w = waw - 2 * BORDERPX;
|
||||||
c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
|
c->rh = c->h; c->h = wah - 2 * BORDERPX;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c->x = c->rx;
|
c->x = c->rx;
|
||||||
@ -64,8 +36,7 @@ togglemax(Client *c)
|
|||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void (*arrange)(Arg *) = DEFMODE;
|
void (*arrange)(void) = DEFMODE;
|
||||||
StackPos stackpos = STACKPOS;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
detach(Client *c) {
|
detach(Client *c) {
|
||||||
@ -79,7 +50,7 @@ detach(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dofloat(Arg *arg) {
|
dofloat(void) {
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
@ -96,97 +67,50 @@ dofloat(Arg *arg) {
|
|||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This algorithm is based on a (M)aster area and a (S)tacking area.
|
|
||||||
* It supports following arrangements:
|
|
||||||
* SSMMM MMMMM MMMSS
|
|
||||||
* SSMMM SSSSS MMMSS
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
dotile(Arg *arg) {
|
dotile(void) {
|
||||||
unsigned int i, n, md, stackw, stackh, tw, th;
|
unsigned int i, n, mpx, stackw, th;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||||
n++;
|
n++;
|
||||||
|
mpx = (waw * master) / 1000;
|
||||||
|
stackw = waw - mpx;
|
||||||
|
|
||||||
if(stackpos == StackBottom) {
|
for(i = 0, c = clients; c; c = c->next)
|
||||||
md = ((sh - bh) * master) / 100;
|
|
||||||
stackw = sw;
|
|
||||||
stackh = sh - bh - md;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
md = (sw * master) / 100;
|
|
||||||
stackw = sw - md;
|
|
||||||
stackh = sh - bh;
|
|
||||||
}
|
|
||||||
|
|
||||||
tw = stackw;
|
|
||||||
if(n > 1)
|
|
||||||
th = stackh / (n - 1);
|
|
||||||
else
|
|
||||||
th = stackh;
|
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c->ismax = False;
|
c->ismax = False;
|
||||||
c->x = sx;
|
c->x = wax;
|
||||||
c->y = sy + bh;
|
c->y = way;
|
||||||
if(n == 1) { /* only 1 window */
|
if(n == 1) { /* only 1 window */
|
||||||
c->w = sw - 2 * BORDERPX;
|
c->w = waw - 2 * BORDERPX;
|
||||||
c->h = sh - 2 * BORDERPX - bh;
|
c->h = wah - 2 * BORDERPX;
|
||||||
}
|
}
|
||||||
else if(i == 0) { /* master window */
|
else if(i == 0) { /* master window */
|
||||||
if(stackpos == StackLeft)
|
c->w = mpx - 2 * BORDERPX;
|
||||||
c->x += stackw;
|
c->h = wah - 2 * BORDERPX;
|
||||||
switch(stackpos) {
|
th = wah / (n - 1);
|
||||||
case StackLeft:
|
|
||||||
case StackRight:
|
|
||||||
c->w = md - 2 * BORDERPX;
|
|
||||||
c->h = sh - bh - 2 * BORDERPX;
|
|
||||||
break;
|
|
||||||
case StackBottom:
|
|
||||||
c->w = sw - 2 * BORDERPX;
|
|
||||||
c->h = md - 2 * BORDERPX;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else { /* tile window */
|
else { /* tile window */
|
||||||
if(stackpos == StackRight)
|
c->x += mpx;
|
||||||
c->x += md;
|
c->w = stackw - 2 * BORDERPX;
|
||||||
if(th > bh) {
|
if(th > bh) {
|
||||||
switch(stackpos) {
|
c->y += (i - 1) * th;
|
||||||
case StackLeft:
|
|
||||||
case StackRight:
|
|
||||||
c->y = sy + (i - 1) * th + bh;
|
|
||||||
if(i + 1 == n)
|
|
||||||
c->h = sh - c->y - 2 * BORDERPX;
|
|
||||||
break;
|
|
||||||
case StackBottom:
|
|
||||||
c->y = sy + md + (i - 1) * th + bh;
|
|
||||||
if(i + 1 == n)
|
|
||||||
c->h = sh - c->y - 2 * BORDERPX;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
c->w = tw - 2 * BORDERPX;
|
|
||||||
c->h = th - 2 * BORDERPX;
|
c->h = th - 2 * BORDERPX;
|
||||||
}
|
}
|
||||||
else { /* fallback if th < bh */
|
else /* fallback if th < bh */
|
||||||
if(stackpos == StackBottom)
|
c->h = wah - 2 * BORDERPX;
|
||||||
c->y += md;
|
|
||||||
c->w = stackw - 2 * BORDERPX;
|
|
||||||
c->h = stackh - 2 * BORDERPX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
}
|
|
||||||
if(!sel || !isvisible(sel)) {
|
if(!sel || !isvisible(sel)) {
|
||||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
focus(c);
|
focus(c);
|
||||||
@ -200,7 +124,6 @@ focusnext(Arg *arg) {
|
|||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!(c = getnext(sel->next)))
|
if(!(c = getnext(sel->next)))
|
||||||
c = getnext(clients);
|
c = getnext(clients);
|
||||||
if(c) {
|
if(c) {
|
||||||
@ -215,7 +138,6 @@ focusprev(Arg *arg) {
|
|||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!(c = getprev(sel->prev))) {
|
if(!(c = getprev(sel->prev))) {
|
||||||
for(c = clients; c && c->next; c = c->next);
|
for(c = clients; c && c->next; c = c->next);
|
||||||
c = getprev(c);
|
c = getprev(c);
|
||||||
@ -237,27 +159,15 @@ isvisible(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resizecol(Arg *arg) {
|
resizemaster(Arg *arg) {
|
||||||
unsigned int n;
|
if(arg->i == 0)
|
||||||
Client *c;
|
master = MASTER;
|
||||||
|
else {
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
if(master + arg->i > 950 || master + arg->i < 50)
|
||||||
if(isvisible(c) && !c->isfloat)
|
|
||||||
n++;
|
|
||||||
if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(sel == getnext(clients)) {
|
|
||||||
if(master + arg->i > 95 || master + arg->i < 5)
|
|
||||||
return;
|
return;
|
||||||
master += arg->i;
|
master += arg->i;
|
||||||
}
|
}
|
||||||
else {
|
arrange();
|
||||||
if(master - arg->i > 95 || master - arg->i < 5)
|
|
||||||
return;
|
|
||||||
master -= arg->i;
|
|
||||||
}
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -290,11 +200,19 @@ restack(void) {
|
|||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglefloat(Arg *arg) {
|
||||||
|
if (!sel || arrange == dofloat)
|
||||||
|
return;
|
||||||
|
sel->isfloat = !sel->isfloat;
|
||||||
|
arrange();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglemode(Arg *arg) {
|
togglemode(Arg *arg) {
|
||||||
arrange = (arrange == dofloat) ? dotile : dofloat;
|
arrange = (arrange == dofloat) ? dotile : dofloat;
|
||||||
if(sel)
|
if(sel)
|
||||||
arrange(NULL);
|
arrange();
|
||||||
else
|
else
|
||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
@ -307,19 +225,7 @@ toggleview(Arg *arg) {
|
|||||||
for(i = 0; i < ntags && !seltag[i]; i++);
|
for(i = 0; i < ntags && !seltag[i]; i++);
|
||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
seltag[arg->i] = True; /* cannot toggle last view */
|
seltag[arg->i] = True; /* cannot toggle last view */
|
||||||
reorder();
|
arrange();
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
togglestackpos(Arg *arg) {
|
|
||||||
if(arrange == dofloat)
|
|
||||||
return;
|
|
||||||
if(stackpos == StackBottom)
|
|
||||||
stackpos = STACKPOS;
|
|
||||||
else
|
|
||||||
stackpos = StackBottom;
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -327,24 +233,11 @@ view(Arg *arg) {
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
seltag[i] = False;
|
seltag[i] = (arg->i == -1) ? True : False;
|
||||||
seltag[arg->i] = True;
|
seltag[arg->i] = True;
|
||||||
reorder();
|
arrange();
|
||||||
arrange(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
viewall(Arg *arg) {
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
|
||||||
seltag[i] = True;
|
|
||||||
reorder();
|
|
||||||
arrange(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom(Arg *arg) {
|
zoom(Arg *arg) {
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
@ -352,18 +245,15 @@ zoom(Arg *arg) {
|
|||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(sel->isfloat || (arrange == dofloat)) {
|
if(sel->isfloat || (arrange == dofloat)) {
|
||||||
togglemax(sel);
|
togglemax(sel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(isvisible(c) && !c->isfloat)
|
if(isvisible(c) && !c->isfloat)
|
||||||
n++;
|
n++;
|
||||||
if(n < 2 || (arrange == dofloat))
|
if(n < 2 || (arrange == dofloat))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((c = sel) == nexttiled(clients))
|
if((c = sel) == nexttiled(clients))
|
||||||
if(!(c = nexttiled(c->next)))
|
if(!(c = nexttiled(c->next)))
|
||||||
return;
|
return;
|
||||||
@ -373,5 +263,5 @@ zoom(Arg *arg) {
|
|||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user