public
Description: This repository is just miscellaneous stuff. It is from my old devjavu SVN repo. Some of this stuff should get it's own repo.
Homepage: http://singpolyma.net/
Clone URL: git://github.com/singpolyma/singpolyma.git
new dwm version
singpolyma (author)
Sat Jan 03 21:06:52 -0800 2009
commit  cda0429418235ac56c49786793b37a79c206ba00
tree    0ab3e0db820d927d16e37d60a54597952e7fbd55
parent  d3fbd21b97fdde9e68416e6135d7a45445ffdd3b
...
1
2
3
 
4
5
6
7
 
 
 
 
8
9
10
11
12
13
 
14
15
16
17
 
 
18
19
20
21
22
23
24
 
 
 
 
 
 
25
...
1
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
17
18
19
 
 
20
21
22
 
 
 
 
 
 
23
24
25
26
27
28
29
0
@@ -1,25 +1,29 @@
0
 MIT/X Consortium License
0
 
0
-© 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
0
+© 2006-2008 Anselm R Garbe <garbeam at gmail dot com>
0
 © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
0
 © 2006-2007 Jukka Salmi <jukka at salmi dot ch>
0
 © 2007 Premysl Hruby <dfenze at gmail dot com>
0
 © 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
0
+© 2007 Christof Musik <christof at sendfax dot de>
0
+© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
0
+© 2007-2008 Peter Hartlich <sgkkr at hartlich dot com>
0
+© 2008 Martin Hurton <martin dot hurton at gmail dot com>
0
 
0
 Permission is hereby granted, free of charge, to any person obtaining a
0
 copy of this software and associated documentation files (the "Software"),
0
 to deal in the Software without restriction, including without limitation
0
 the rights to use, copy, modify, merge, publish, distribute, sublicense,
0
-and/or sell copies of the Software, and to permit persons to whom the 
0
+and/or sell copies of the Software, and to permit persons to whom the
0
 Software is furnished to do so, subject to the following conditions:
0
 
0
-The above copyright notice and this permission notice shall be included in 
0
-all copies or substantial portions of the Software. 
0
+The above copyright notice and this permission notice shall be included in
0
+all copies or substantial portions of the Software.
0
 
0
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
0
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
0
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
0
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
0
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
0
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
0
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0
 DEALINGS IN THE SOFTWARE.
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # dwm - dynamic window manager
0
-# © 2006-2007 Anselm R. Garbe, Sander van Dijk
0
+# See LICENSE file for copyright and license details.
0
 
0
 include config.mk
0
 
...
1
 
 
2
3
4
...
 
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
-This is a small "fork" that I use myself, mostly changes to config.h.
0
+This is my own little "fork" that I use... mostly changes to config.h
0
+
0
 
0
 dwm - dynamic window manager
0
 ============================
...
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
 
 
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
45
46
47
48
49
50
51
 
 
 
 
 
 
 
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
...
1
2
3
 
 
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
 
 
 
 
 
 
41
42
43
44
45
46
47
48
49
50
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
0
@@ -1,125 +1,125 @@
0
 /* See LICENSE file for copyright and license details. */
0
 
0
 /* appearance */
0
-#define BARPOS      BarTop /* BarBot, BarOff */
0
-#define BORDERPX      1
0
-#define FONT        "-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*"
0
-#define NORMBORDERCOLOR  "#cccccc"
0
-#define NORMBGCOLOR    "#cccccc"
0
-#define NORMFGCOLOR    "#000000"
0
-#define SELBORDERCOLOR  "#0033aa"
0
-#define SELBGCOLOR    "#0033aa"
0
-#define SELFGCOLOR    "#ffffff"
0
+static const char font[]            = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*";
0
+static const char normbordercolor[] = "#cccccc";
0
+static const char normbgcolor[]     = "#cccccc";
0
+static const char normfgcolor[]     = "#000000";
0
+static const char selbordercolor[]  = "#0066ff";
0
+static const char selbgcolor[]      = "#0066ff";
0
+static const char selfgcolor[]      = "#ffffff";
0
+static unsigned int borderpx        = 1;        /* border pixel of windows */
0
+static unsigned int snap            = 32;       /* snap pixel */
0
+static Bool showbar                 = True;     /* False means no bar */
0
+static Bool topbar                  = True;     /* False means bottom bar */
0
+static Bool readin                  = True;     /* False means do not read stdin */
0
+static Bool usegrab                 = False;    /* True means grabbing the X server
0
+                                                   during mouse-based resizals */
0
 
0
 /* tagging */
0
-const char *tags[] = { "www", "term", "chat", "mail", "5", "6", "7", "8", "media" };
0
+static const char tags[][MAXTAGLEN] = { "www", "term", "chat", "mail", "5", "6", "7", "8", "media" };
0
+static unsigned int tagset[] = {2, 2}; /* after start, first tag is selected */
0
+
0
 static Rule rules[] = {
0
-  /* class:instance:title regex  tags regex  isfloating */
0
-  { "Gimp",          NULL,      True },
0
-  { "Network Settings",  NULL,     True },
0
-  { "gksu",          NULL,      True },
0
-  { "System Monitor",    NULL,      True },
0
-  { "MPlayer",        "media",    True },
0
-  { "Rhythmbox",        "media",    False },
0
-  { "cmus",          "media",    False },
0
-  { "mediacentre",      "media",    False },
0
-  { "totem",          "media",    False },
0
-  { "Firefox",        "www",    False },
0
-  { "Flock",          "www",    False },
0
-  { "Gecko",          "www",    False },
0
-  { "lynx",          "www",    False },
0
-  { "links2",          "www",    False },
0
-  { "w3m",            "www",    False },
0
-  { "psi",            "chat",    False },
0
-  { "chat",          "chat",    False },
0
-  { "gaim",          "chat",    False },
0
-  { "sic",            "chat",    False },
0
-  { "rxvt",          "term",    False },
0
-  { "gedit",          "term",    False },
0
-  { "thunar",          "term",    False },
0
-  { "pdmenu",          ".*",      False },
0
-  { "mutt",          "mail",      False },
0
+  /* class      instance    title       tags mask     isfloating */
0
+  { "Gimp",     NULL,       NULL,       0,            True },
0
+  { NULL,       NULL,       "Passphrase",       0,    True },
0
+  { NULL,       NULL,       "Network Settings", 0, True },
0
+  { NULL,       NULL,       "gksu",             0, True },
0
+  { NULL,       NULL,       "System Monitor",   0, True },
0
+  { "Firefox",  NULL,       NULL,       1 << 0,       False },
0
+  { "URxvt",    NULL,       NULL,       1 << 1,       False },
0
+  { "Gedit",    NULL,       NULL,       1 << 1,       False },
0
+  { "Thunar",   NULL,       NULL,       1 << 1,       False },
0
+  { NULL,       NULL,       "Psi",      1 << 2,       False },
0
+  { NULL,       NULL,       "mutt",     1 << 3,       False },
0
+  { NULL,       NULL,       "cmus",     1 << 8,       False },
0
+  { NULL,       NULL,       "mediacentre",      1 << 8,       False },
0
 };
0
 
0
 /* layout(s) */
0
-#define ISTILE      isarrange(tile) /* || isarrange(<custom>) */
0
-#define MWFACT      0.6  /* master width factor [0.1 .. 0.9] */
0
-#define SNAP      32  /* snap pixel */
0
-Layout layouts[] = {
0
-  /* symbol    function */
0
-  { "[]=",    tile }, /* first entry is default */
0
-  { "><>",    floating },
0
+static float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
0
+static Bool resizehints = True; /* False means respect size hints in tiled resizals */
0
+
0
+static Layout layouts[] = {
0
+  /* symbol     arrange function */
0
+  { "[]=",      tile },    /* first entry is default */
0
+  { "><>",      NULL },    /* no layout function means floating behavior */
0
+  { "[M]",      monocle },
0
 };
0
 
0
 /* key definitions */
0
-#define MODKEY      Mod1Mask
0
-#define KEYS \
0
-Key keys[] = { \
0
-  /* modifier      key    function  argument */ \
0
-  { MODKEY|ShiftMask,      XK_Return,  spawn,    "exec urxvt" }, \
0
-  { MODKEY|ControlMask,    XK_Return,  spawn,    "exec urxvt -e pdmenu -c -u" }, \
0
-  { MODKEY|ControlMask,    XK_space,    spawn,    "dmenu_path | dmenu | history-exec" }, \
0
-  { MODKEY|ControlMask|ShiftMask, XK_space,  spawn,     "lsw -visible | dmenu" }, \
0
-  { MODKEY|ControlMask,    XK_y,      spawn,     "echo \"y `echo \"- uwace\n- jobmine\n- quest\" | dmenu`\" | history-exec" }, \
0
-  { 0,          XK_F4,    spawn,     "exec rxvt" }, \
0
-  { 0,          XK_F5,    spawn,     "thunar ~/" }, \
0
-  { 0,          XK_F6,    spawn,     "exec urxvt -name cmus -e cmus" }, \
0
-  { MODKEY,      XK_F6,    spawn,     "exec urxvt -name mediacentre -e ssh singpolyma.dnsalias.net" }, \
0
-  { 0,          XK_F7,    spawn,     "firefox" }, \
0
-  { MODKEY,      XK_F7,    spawn,     "psi" }, \
0
-  { 0,          XK_F8,    spawn,     "exec urxvt -name mutt -e mutt" }, \
0
-  { MODKEY|ControlMask,    XK_n,    spawn,     "network-admin" }, \
0
-  { MODKEY|ControlMask,    XK_l,    spawn,     "sleep 0.1 && slock" }, \
0
-  { MODKEY|ControlMask,    XK_Delete,  spawn,     "gnome-power-cmd.sh shutdown" }, \
0
-  { MODKEY,      XK_space,  setlayout,  NULL }, \
0
-  { MODKEY,      XK_b,    togglebar,  NULL }, \
0
-  { MODKEY,      XK_Tab,    focusprev,  NULL }, \
0
-  { MODKEY,      XK_Tab,    zoom,     NULL }, \
0
-  { MODKEY,      XK_j,    focusnext,  NULL }, \
0
-  { MODKEY,      XK_k,    focusprev,  NULL }, \
0
-  { MODKEY,      XK_h,    setmwfact,  "-0.05" }, \
0
-  { MODKEY,      XK_l,    setmwfact,  "+0.05" }, \
0
-  { MODKEY,      XK_m,    togglemax,  NULL }, \
0
-  { MODKEY,      XK_Return,  zoom,    NULL }, \
0
-  { MODKEY|ShiftMask,    XK_space,  togglefloating,  NULL }, \
0
-  { MODKEY,      XK_F4,    killclient,  NULL }, \
0
-  { MODKEY,      XK_0,    view,    NULL }, \
0
-  { MODKEY,      XK_1,    view,    tags[0] }, \
0
-  { MODKEY,      XK_2,    view,    tags[1] }, \
0
-  { MODKEY,      XK_3,    view,    tags[2] }, \
0
-  { MODKEY,      XK_4,    view,    tags[3] }, \
0
-  { MODKEY,      XK_5,    view,    tags[4] }, \
0
-  { MODKEY,      XK_6,    view,    tags[5] }, \
0
-  { MODKEY,      XK_7,    view,    tags[6] }, \
0
-  { MODKEY,      XK_8,    view,    tags[7] }, \
0
-  { MODKEY,      XK_9,    view,    tags[8] }, \
0
-  { MODKEY|ControlMask,    XK_1,    toggleview,  tags[0] }, \
0
-  { MODKEY|ControlMask,    XK_2,    toggleview,  tags[1] }, \
0
-  { MODKEY|ControlMask,    XK_3,    toggleview,  tags[2] }, \
0
-  { MODKEY|ControlMask,    XK_4,    toggleview,  tags[3] }, \
0
-  { MODKEY|ControlMask,    XK_5,    toggleview,  tags[4] }, \
0
-  { MODKEY|ControlMask,    XK_6,    toggleview,  tags[5] }, \
0
-  { MODKEY|ControlMask,    XK_7,    toggleview,  tags[6] }, \
0
-  { MODKEY|ControlMask,    XK_8,    toggleview,  tags[7] }, \
0
-  { MODKEY|ControlMask,    XK_9,    toggleview,  tags[8] }, \
0
-  { MODKEY|ShiftMask,    XK_0,    tag,    NULL }, \
0
-  { MODKEY|ShiftMask,    XK_1,    tag,    tags[0] }, \
0
-  { MODKEY|ShiftMask,    XK_2,    tag,    tags[1] }, \
0
-  { MODKEY|ShiftMask,    XK_3,    tag,    tags[2] }, \
0
-  { MODKEY|ShiftMask,    XK_4,    tag,    tags[3] }, \
0
-  { MODKEY|ShiftMask,    XK_5,    tag,    tags[4] }, \
0
-  { MODKEY|ShiftMask,    XK_6,    tag,    tags[5] }, \
0
-  { MODKEY|ShiftMask,    XK_7,    tag,    tags[6] }, \
0
-  { MODKEY|ShiftMask,    XK_8,    tag,    tags[7] }, \
0
-  { MODKEY|ShiftMask,    XK_9,    tag,    tags[8] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_1,    toggletag,  tags[0] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_2,    toggletag,  tags[1] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_3,    toggletag,  tags[2] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_4,    toggletag,  tags[3] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_5,    toggletag,  tags[4] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_6,    toggletag,  tags[5] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_7,    toggletag,  tags[6] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_8,    toggletag,  tags[7] }, \
0
-  { MODKEY|ControlMask|ShiftMask,  XK_9,    toggletag,  tags[8] }, \
0
-  { MODKEY|ShiftMask,    XK_q,    quit,    NULL }, \
0
+#define MODKEY Mod1Mask
0
+#define TAGKEYS(KEY,TAG) \
0
+  { MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
0
+  { MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
0
+  { MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
0
+  { MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },
0
+
0
+/* helper for spawning shell commands in the pre dwm-5.0 fashion */
0
+#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
0
+
0
+/* commands */
0
+static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
0
+static const char *termcmd[]  = { "rxvt", NULL };
0
+
0
+static Key keys[] = {
0
+  /* modifier                     key        function        argument */
0
+  { MODKEY|ControlMask,           XK_space,  spawn,          {.v = dmenucmd } },
0
+  { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
0
+  { 0,                            XK_F4,     spawn,          {.v = termcmd } },
0
+  { 0,                            XK_F5,     spawn,          SHCMD("thunar ~/") },
0
+  { 0,                            XK_F6,     spawn,          SHCMD("exec xterm -name cmus -e cmus") },
0
+  { MODKEY,                       XK_F6,     spawn,          SHCMD("exec xterm -name mediacentre -e ssh singpolyma.dnsalias.net") },
0
+  { 0,                            XK_F7,     spawn,          SHCMD("sensible-browser") },
0
+  { MODKEY,                       XK_F7,     spawn,          SHCMD("psi") },
0
+  { 0,                            XK_F8,     spawn,          SHCMD("exec xterm -name mutt -e mutt") },
0
+  { MODKEY|ControlMask,           XK_l,      spawn,          SHCMD("sleep 0.1 && slock") },
0
+  { MODKEY|ControlMask,           XK_Delete, spawn,          SHCMD("gnome-power-cmd.sh shutdown") },
0
+  { MODKEY,                       XK_Tab,    focusstack,     {.i = -1} },
0
+  { MODKEY,                       XK_Tab,    zoom,           {0} },
0
+  { MODKEY,                       XK_F4,     killclient,     {0} },
0
+  { MODKEY,                       XK_b,      togglebar,      {0} },
0
+  { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
0
+  { MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
0
+  { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
0
+  { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
0
+  { MODKEY,                       XK_Return, zoom,           {0} },
0
+  { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
0
+  { MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
0
+  { MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
0
+  { MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
0
+  { MODKEY,                       XK_space,  setlayout,      {0} },
0
+  { MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
0
+  { MODKEY,                       XK_0,      view,           {.ui = ~0 } },
0
+  { MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
0
+  TAGKEYS(                        XK_1,                      0)
0
+  TAGKEYS(                        XK_2,                      1)
0
+  TAGKEYS(                        XK_3,                      2)
0
+  TAGKEYS(                        XK_4,                      3)
0
+  TAGKEYS(                        XK_5,                      4)
0
+  TAGKEYS(                        XK_6,                      5)
0
+  TAGKEYS(                        XK_7,                      6)
0
+  TAGKEYS(                        XK_8,                      7)
0
+  TAGKEYS(                        XK_9,                      8)
0
+  { MODKEY|ShiftMask,             XK_q,      quit,           {0} },
0
+};
0
+
0
+/* button definitions */
0
+/* click can be a tag number (starting at 0),
0
+ * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
0
+static Button buttons[] = {
0
+  /* click                event mask      button          function        argument */
0
+  { ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
0
+  { ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
0
+  { ClkWinTitle,          0,              Button2,        zoom,           {0} },
0
+  { ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
0
+  { ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
0
+  { ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
0
+  { ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
0
+  { ClkTagBar,            0,              Button1,        view,           {0} },
0
+  { ClkTagBar,            0,              Button3,        toggleview,     {0} },
0
+  { ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
0
+  { ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
0
 };
0
+
...
1
2
 
3
4
5
6
7
 
8
9
10
11
12
 
 
 
 
13
14
15
 
16
17
18
 
 
19
20
21
22
23
24
25
26
27
28
29
...
1
 
2
3
4
5
6
 
7
8
9
10
11
12
13
14
15
16
17
18
 
19
20
21
 
22
23
24
 
 
25
26
27
28
 
29
30
31
0
@@ -1,29 +1,31 @@
0
 # dwm version
0
-VERSION = 4.6
0
+VERSION = 5.3.1
0
 
0
 # Customize below to fit your system
0
 
0
 # paths
0
-PREFIX = /usr
0
+PREFIX = /usr/local
0
 MANPREFIX = ${PREFIX}/share/man
0
 
0
 X11INC = /usr/X11R6/include
0
 X11LIB = /usr/X11R6/lib
0
 
0
+# Xinerama, un-comment if you want it
0
+#XINERAMALIBS = -L${X11LIB} -lXinerama
0
+#XINERAMAFLAGS = -DXINERAMA
0
+
0
 # includes and libs
0
 INCS = -I. -I/usr/include -I${X11INC}
0
-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
0
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
0
 
0
 # flags
0
-CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
0
+CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
0
+CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
0
 LDFLAGS = -s ${LIBS}
0
-CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
0
-LDFLAGS = -g ${LIBS}
0
 
0
 # Solaris
0
 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
0
 #LDFLAGS = ${LIBS}
0
-#CFLAGS += -xtarget=ultra
0
 
0
 # compiler and linker
0
 CC = cc
...
5
6
7
8
9
 
 
10
11
12
 
13
14
15
16
 
 
 
 
17
18
19
20
21
22
23
 
24
25
26
...
56
57
58
59
60
 
 
61
62
63
 
 
64
65
66
 
 
67
68
69
 
 
 
 
 
70
71
72
...
74
75
76
 
 
 
77
78
 
79
80
81
 
 
 
 
 
 
 
 
 
 
 
82
83
84
85
86
 
87
88
89
 
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
104
105
106
...
120
121
122
123
 
124
125
126
 
127
128
129
 
130
131
132
...
147
148
149
150
 
151
152
153
...
5
6
7
 
 
8
9
10
11
 
12
13
 
 
 
14
15
16
17
18
19
20
21
22
23
 
24
25
26
27
...
57
58
59
 
 
60
61
62
 
 
63
64
65
 
 
66
67
68
 
 
69
70
71
72
73
74
75
76
...
78
79
80
81
82
83
84
 
85
86
 
 
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
102
103
104
 
105
106
107
108
109
 
 
 
 
 
 
 
 
 
 
110
111
112
113
...
127
128
129
 
130
131
132
 
133
134
135
 
136
137
138
139
...
154
155
156
 
157
158
159
160
0
@@ -5,22 +5,23 @@ dwm \- dynamic window manager
0
 .B dwm
0
 .RB [ \-v ]
0
 .SH DESCRIPTION
0
-dwm is a dynamic window manager for X. It manages windows in tiled and
0
-floating layouts. Either layout can be applied dynamically, optimizing the
0
+dwm is a dynamic window manager for X. It manages windows in tiled, monocle
0
+and floating layouts. Either layout can be applied dynamically, optimising the
0
 environment for the application in use and the task performed.
0
 .P
0
-In tiled layout windows are managed in a master and stacking area. The master
0
+In tiled layouts windows are managed in a master and stacking area. The master
0
 area contains the window which currently needs most attention, whereas the
0
-stacking area contains all other windows. In floating layout windows can be
0
-resized and moved freely. Dialog windows are always managed floating,
0
-regardless of the layout applied.
0
+stacking area contains all other windows. In monocle layout all windows are
0
+maximised to the screen size. In floating layout windows can be resized and
0
+moved freely. Dialog windows are always managed floating, regardless of the
0
+layout applied.
0
 .P
0
 Windows are grouped by tags. Each window can be tagged with one or multiple
0
 tags. Selecting certain tags displays all windows with these tags.
0
 .P
0
 dwm contains a small status bar which displays all available tags, the layout,
0
 the title of the focused window, and the text read from standard input. A
0
-floating window is indicated with an empty square and a maximized
0
+floating window is indicated with an empty square and a maximised
0
 floating window is indicated with a filled square before the windows
0
 title.  The selected tags are indicated with a different color. The tags of
0
 the focused window are indicated with a filled square in the top left
0
@@ -56,17 +57,20 @@ click on a tag label adds/removes that tag to/from the focused window.
0
 Start
0
 .BR xterm.
0
 .TP
0
-.B Mod1\-Return
0
-Zooms/cycles current window to/from master area (tiled layout only).
0
+.B Mod1\-b
0
+Toggles bar on and off.
0
 .TP
0
-.B Mod1\-Tab
0
-Toggles to the previously selected tags.
0
+.B Mod1\-t
0
+Sets tiled layout.
0
 .TP
0
-.B Mod1\-b
0
-Shows/hides the status bar.
0
+.B Mod1\-f
0
+Sets floating layout.
0
 .TP
0
-.B Mod1\-h
0
-Decreases the master area width about 5% (tiled layout only).
0
+.B Mod1\-m
0
+Sets monocle layout.
0
+.TP
0
+.B Mod1\-space
0
+Toggles between current and previous layout.
0
 .TP
0
 .B Mod1\-j
0
 Focus next window.
0
@@ -74,33 +78,36 @@ Focus next window.
0
 .B Mod1\-k
0
 Focus previous window.
0
 .TP
0
+.B Mod1\-h
0
+Decrease master area size.
0
+.TP
0
 .B Mod1\-l
0
-Increases the master area width about 5% (tiled layout only).
0
+Increase master area size.
0
 .TP
0
-.B Mod1\-m
0
-Toggles maximization of current window.
0
+.B Mod1\-Return
0
+Zooms/cycles focused window to/from master area (tiled layouts only).
0
+.TP
0
+.B Mod1\-Shift\-c
0
+Close focused window.
0
+.TP
0
+.B Mod1\-Shift\-space
0
+Toggle focused window between tiled and floating state.
0
+.TP
0
+.B Mod1\-Tab
0
+Toggles to the previously selected tags.
0
 .TP
0
 .B Mod1\-Shift\-[1..n]
0
 Apply
0
 .RB nth
0
-tag to current window.
0
+tag to focused window.
0
 .TP
0
 .B Mod1\-Shift\-0
0
-Apply all tags to current window.
0
+Apply all tags to focused window.
0
 .TP
0
 .B Mod1\-Control\-Shift\-[1..n]
0
 Add/remove
0
 .B nth
0
-tag to/from current window.
0
-.TP
0
-.B Mod1\-Shift\-c
0
-Close focused window.
0
-.TP
0
-.B Mod1\-space
0
-Toggle between tiled and floating layout (affects all windows).
0
-.TP
0
-.B Mod1\-Shift\-space
0
-Toggle focused window between tiled and floating state.
0
+tag to/from focused window.
0
 .TP
0
 .B Mod1\-[1..n]
0
 View all windows with
0
@@ -120,13 +127,13 @@ Quit dwm.
0
 .SS Mouse commands
0
 .TP
0
 .B Mod1\-Button1
0
-Move current window while dragging. Tiled windows will be toggled to the floating state.
0
+Move focused window while dragging. Tiled windows will be toggled to the floating state.
0
 .TP
0
 .B Mod1\-Button2
0
-Zooms/cycles current window to/from master area. If it is floating (but not fixed) it will be toggled to the tiled state instead.
0
+Toggles focused window between floating and tiled state.
0
 .TP
0
 .B Mod1\-Button3
0
-Resize current window while dragging. Tiled windows will be toggled to the floating state.
0
+Resize focused window while dragging. Tiled windows will be toggled to the floating state.
0
 .SH CUSTOMIZATION
0
 dwm is customized by creating a custom config.h and (re)compiling the source
0
 code. This keeps it fast, secure and simple.
0
@@ -147,7 +154,7 @@ can set the following environment variable (to use the older Motif
0
 backend instead):
0
 .BR AWT_TOOLKIT=MToolkit .
0
 .P
0
-Recent GTK 2.10.9+ versions contain a broken
0
+GTK 2.10.9+ versions contain a broken
0
 .BR Save\-As
0
 file dialog implementation,
0
 which requests to reconfigure its window size in an endless loop. However, its
...
15
16
17
18
19
20
21
22
 
 
 
23
24
25
...
35
36
37
38
39
40
41
42
43
44
 
 
 
45
46
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
58
59
60
61
 
62
63
64
65
66
67
68
69
 
 
 
70
71
72
73
74
...
89
90
91
92
 
93
94
95
 
 
96
97
98
...
101
102
103
104
105
 
 
 
 
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
194
195
196
197
198
199
200
201
202
203
204
205
 
 
 
 
 
 
 
 
 
206
207
208
209
210
211
212
 
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
 
 
 
 
 
 
 
 
 
 
 
232
233
234
235
236
237
 
 
238
239
240
241
242
243
244
245
 
 
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
 
 
 
 
 
 
 
 
261
262
263
264
265
266
267
268
 
 
 
 
 
 
 
269
270
271
272
273
274
275
276
277
278
279
280
 
281
 
 
282
283
284
285
286
287
288
289
290
291
...
297
298
299
300
301
302
303
304
305
306
307
308
309
 
 
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
 
 
 
 
 
 
 
332
333
334
 
 
 
 
 
 
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
 
360
 
 
 
 
 
361
362
363
364
365
366
 
367
368
369
 
370
371
372
373
374
375
 
 
376
377
378
379
380
 
 
 
381
382
383
 
 
 
384
385
386
387
388
...
390
391
392
393
394
395
396
397
 
398
 
399
400
401
402
403
404
 
 
405
406
 
 
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
 
 
 
426
427
428
...
437
438
439
440
 
441
442
443
...
450
451
452
453
454
455
456
 
 
457
458
459
...
465
466
467
468
469
470
471
 
 
472
473
 
474
475
 
476
477
478
479
480
481
482
483
484
485
 
 
 
 
 
486
487
 
488
489
490
...
514
515
516
517
518
519
520
521
522
523
 
 
 
 
524
525
526
527
528
529
530
 
531
532
533
534
 
 
 
 
 
 
 
 
 
 
535
536
537
538
539
540
541
542
543
544
545
546
547
548
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
550
551
552
553
554
555
 
 
 
 
 
 
 
 
 
556
557
558
 
559
560
 
561
562
563
564
565
 
 
566
567
568
 
569
570
 
571
572
573
574
575
 
576
577
578
579
580
 
581
582
583
...
593
594
595
596
597
598
599
 
 
 
600
601
602
 
603
604
605
606
607
608
609
610
611
 
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
 
 
 
 
 
 
 
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
 
650
651
652
653
654
 
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
 
 
686
687
688
689
690
691
 
 
692
693
694
695
696
 
 
697
698
699
700
701
702
703
704
705
706
707
708
709
710
 
 
711
712
713
714
715
 
 
716
717
718
719
720
721
722
723
724
725
 
 
726
727
728
729
730
 
 
731
732
733
734
735
736
737
 
 
 
 
 
 
 
 
 
 
 
 
 
738
739
740
...
756
757
758
759
 
760
761
762
...
794
795
796
797
798
 
799
800
801
...
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
 
 
 
 
 
 
 
 
 
 
 
 
 
839
840
841
842
843
844
845
846
847
 
 
 
 
 
 
 
848
849
850
 
 
 
 
 
 
 
 
851
852
853
...
856
857
858
859
860
861
862
863
...
872
873
874
875
876
877
878
 
 
879
880
881
882
883
884
885
886
887
888
 
889
890
891
...
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
...
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
 
963
964
965
966
967
968
 
 
 
969
970
971
972
 
973
974
975
...
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
 
1002
1003
1004
 
1005
1006
1007
1008
 
 
 
1009
 
 
1010
1011
1012
1013
1014
 
1015
1016
1017
1018
 
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
 
 
 
 
 
 
 
 
1030
1031
 
 
1032
1033
1034
1035
1036
1037
 
1038
1039
1040
1041
 
 
1042
1043
1044
 
 
 
1045
1046
 
 
 
1047
1048
1049
1050
 
1051
1052
1053
...
1059
1060
1061
1062
 
1063
1064
1065
...
1076
1077
1078
1079
1080
 
 
 
 
 
 
 
 
 
 
1081
 
1082
1083
1084
1085
1086
 
 
 
 
 
1087
1088
 
1089
1090
1091
1092
1093
 
 
 
 
 
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1116
1117
1118
 
 
 
 
1119
1120
1121
1122
1123
 
1124
1125
1126
...
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
 
 
 
 
 
 
 
 
 
 
 
 
 
1146
1147
1148
...
1153
1154
1155
1156
 
1157
1158
1159
...
1162
1163
1164
 
 
 
1165
1166
1167
1168
1169
 
 
1170
1171
1172
1173
 
 
 
 
1174
1175
1176
1177
1178
1179
1180
 
 
 
 
 
 
 
 
 
 
1181
1182
1183
...
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
 
 
 
 
 
 
 
 
1201
1202
1203
1204
1205
1206
1207
1208
1209
 
 
 
 
 
1210
1211
 
1212
 
 
 
 
1213
1214
1215
1216
1217
1218
1219
 
 
 
1220
1221
1222
1223
1224
1225
1226
 
1227
1228
 
1229
1230
 
 
 
1231
1232
1233
1234
 
1235
1236
1237
1238
1239
 
 
 
 
 
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
 
 
 
 
 
 
 
 
 
 
 
1259
1260
1261
 
 
 
 
 
 
1262
1263
1264
...
1270
1271
1272
1273
 
1274
1275
 
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
 
 
 
 
 
1288
1289
1290
...
1293
1294
1295
1296
 
1297
 
 
1298
1299
1300
1301
1302
1303
 
 
 
1304
1305
1306
...
1309
1310
1311
1312
 
1313
1314
1315
 
1316
1317
1318
 
1319
1320
1321
...
1323
1324
1325
1326
1327
1328
1329
 
 
 
 
 
 
 
 
 
 
 
 
1330
1331
1332
...
1341
1342
1343
1344
 
1345
1346
1347
1348
1349
1350
...
1360
1361
1362
 
 
1363
1364
1365
1366
1367
1368
...
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
 
 
 
 
 
1392
1393
1394
1395
1396
1397
 
1398
1399
1400
 
 
1401
1402
 
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
 
 
 
 
1417
1418
1419
1420
1421
1422
1423
1424
1425
 
 
1426
1427
 
 
 
 
 
 
 
 
 
 
 
 
 
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
 
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
 
 
 
 
 
 
 
 
 
 
 
1489
1490
1491
 
 
 
 
 
1492
1493
1494
1495
1496
1497
 
 
 
 
 
1498
1499
1500
1501
1502
1503
1504
1505
1506
 
1507
1508
1509
 
 
 
 
 
 
 
 
 
 
 
1510
1511
1512
1513
1514
1515
1516
1517
1518
 
 
1519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1520
1521
1522
...
1524
1525
1526
1527
1528
 
 
1529
1530
1531
...
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
 
 
 
 
 
1546
1547
1548
 
1549
1550
1551
...
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
 
 
 
 
1614
1615
1616
1617
1618
 
1619
1620
1621
 
1622
1623
1624
1625
1626
1627
1628
1629
 
 
1630
1631
 
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
 
 
 
 
 
1650
1651
1652
1653
1654
1655
1656
1657
 
 
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
 
 
 
 
1687
1688
1689
1690
1691
1692
1693
 
1694
1695
1696
...
1701
1702
1703
1704
1705
1706
1707
...
1719
1720
1721
1722
1723
 
 
 
 
 
 
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1742
1743
1744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1745
1746
1747
...
1749
1750
1751
1752
1753
1754
1755
 
 
 
 
1756
1757
1758
1759
 
1760
1761
1762
1763
1764
1765
 
1766
1767
1768
1769
1770
1771
 
1772
1773
1774
1775
1776
1777
 
1778
1779
1780
1781
 
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
 
 
 
1792
1793
1794
 
1795
1796
 
1797
1798
1799
1800
1801
1802
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1803
1804
1805
...
1813
1814
1815
 
1816
1817
1818
1819
1820
 
1821
1822
1823
1824
1825
 
1826
1827
1828
1829
1830
1831
1832
 
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
 
 
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
 
1863
1864
1865
 
 
1866
1867
1868
...
1873
1874
1875
1876
 
1877
1878
 
 
 
 
1879
1880
1881
1882
1883
1884
 
1885
1886
1887
1888
1889
1890
1891
...
15
16
17
 
 
 
 
 
18
19
20
21
22
23
...
33
34
35
 
36
37
38
39
40
41
42
43
44
45
46
 
 
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
 
 
 
 
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
84
85
86
87
88
 
89
 
 
 
 
 
90
91
92
93
 
94
95
96
...
111
112
113
 
114
115
 
 
116
117
118
119
120
...
123
124
125
 
 
126
127
128
129
130
131
132
 
 
 
 
 
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
 
 
 
 
 
 
 
 
 
 
 
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
222
223
224
225
226
227
228
229
 
 
 
 
 
 
 
 
 
 
 
 
 
230
231
232
233
234
235
236
237
238
239
240
241
242
243
 
 
 
244
245
246
247
248
249
 
 
 
 
250
251
252
253
254
 
 
 
 
 
 
 
 
 
 
 
 
255
256
257
258
259
260
261
262
263
264
 
 
 
 
 
 
265
266
267
268
269
270
271
272
273
274
275
 
 
 
 
 
 
 
 
276
277
278
279
280
281
282
283
284
 
 
285
286
287
...
293
294
295
 
 
 
 
 
 
 
 
296
 
297
298
299
300
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
303
304
305
306
307
308
309
 
 
310
311
312
313
314
315
316
317
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
320
321
322
323
324
325
326
327
328
329
330
 
331
332
333
 
334
335
336
 
 
 
 
337
338
339
340
341
342
343
344
345
346
347
 
 
348
349
350
351
 
352
353
354
...
356
357
358
 
359
360
361
 
362
363
364
365
366
367
 
 
 
368
369
370
 
371
372
373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
375
376
377
378
379
...
388
389
390
 
391
392
393
394
...
401
402
403
 
 
 
 
404
405
406
407
408
...
414
415
416
 
417
 
 
418
419
420
 
421
422
 
423
424
425
426
427
 
 
 
 
 
 
428
429
430
431
432
433
 
434
435
436
437
...
461
462
463
 
 
 
 
 
 
 
464
465
466
467
468
469
470
471
472
473
 
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
 
 
 
 
 
 
 
 
 
 
 
 
 
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
 
 
 
 
 
509
510
511
512
513
514
515
516
517
518
519
 
520
521
 
522
523
524
525
 
 
526
527
528
529
 
530
531
 
532
533
534
535
536
 
537
538
539
540
541
 
542
543
544
545
...
555
556
557
 
 
 
 
558
559
560
561
562
 
563
564
565
566
 
 
 
 
 
 
567
568
569
570
571
 
 
 
 
 
 
 
 
 
 
 
 
 
572
573
574
575
576
577
578
579
580
581
582
583
584
 
 
 
 
 
 
 
 
 
585
586
587
588
589
 
590
591
592
593
 
 
594
595
 
 
 
 
 
 
 
 
 
 
 
596
597
598
599
600
601
 
 
 
 
 
 
 
 
 
 
 
 
 
602
603
604
605
606
607
 
 
608
609
610
611
612
613
614
615
616
617
618
619
 
 
 
 
 
 
620
621
622
623
624
625
626
627
628
629
 
 
630
631
632
 
 
 
 
 
 
 
 
 
633
634
635
636
637
 
 
638
639
640
641
642
 
 
 
 
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
...
674
675
676
 
677
678
679
680
...
712
713
714
 
 
715
716
717
718
...
724
725
726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
728
729
730
731
732
733
734
735
736
737
738
739
740
 
 
 
741
742
 
 
 
743
744
745
746
747
748
749
750
 
 
751
752
753
754
755
756
757
758
759
760
761
...
764
765
766
 
 
767
768
769
...
778
779
780
 
 
 
 
781
782
783
784
785
786
 
 
 
787
788
 
789
790
791
792
...
794
795
796
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
797
798
799
...
808
809
810
 
 
 
 
 
 
 
 
 
 
811
812
 
 
813
 
814
815
816
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
818
 
819
820
 
 
 
 
 
821
822
823
824
825
826
 
827
828
829
830
...
843
844
845
 
 
 
 
 
 
 
 
 
 
846
847
848
 
 
849
850
851
 
 
852
853
854
855
856
857
858
859
860
861
 
862
863
864
865
 
866
867
868
 
 
 
 
 
 
 
 
 
869
870
871
872
873
874
875
876
877
 
878
879
880
881
882
883
 
 
884
885
886
 
 
887
888
889
 
 
890
891
892
893
 
894
895
896
897
898
 
 
899
900
901
902
...
908
909
910
 
911
912
913
914
...
925
926
927
 
 
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
 
 
943
944
945
946
947
948
 
949
950
 
 
 
 
951
952
953
954
955
956
 
 
 
957
958
959
960
961
962
 
 
 
 
 
 
 
 
 
 
 
 
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
 
991
992
993
994
...
1002
1003
1004
 
 
 
 
 
 
 
 
 
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
...
1025
1026
1027
 
1028
1029
1030
1031
...
1034
1035
1036
1037
1038
1039
1040
 
 
 
 
1041
1042
1043
 
 
 
1044
1045
1046
1047
1048
1049
 
 
 
 
 
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
...
1069
1070
1071
 
 
 
 
 
 
 
 
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
 
 
 
 
 
 
1083
1084
1085
1086
1087
1088
 
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
 
 
1100
1101
1102
1103
1104
1105
1106
1107
1108
 
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
 
1121
1122
 
 
 
 
1123
1124
1125
1126
1127
1128
 
 
 
 
 
 
1129
1130
1131
1132
1133
1134
 
 
 
 
 
 
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
...
1163
1164
1165
 
1166
1167
 
1168
1169
1170
 
 
 
 
 
 
 
 
 
 
1171
1172
1173
1174
1175
1176
1177
1178
...
1181
1182
1183
 
1184
1185
1186
1187
1188
1189
1190
1191
1192
 
1193
1194
1195
1196
1197
1198
...
1201
1202
1203
 
1204
1205
1206
 
1207
1208
 
 
1209
1210
1211
1212
...
1214
1215
1216
 
 
 
 
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
...
1240
1241
1242
 
1243
1244
1245
 
1246
1247
1248
...
1258
1259
1260
1261
1262
1263
 
 
1264
1265
1266
...
1272
1273
1274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
 
 
1288
1289
1290
 
1291
1292
 
 
 
 
 
 
 
 
 
 
 
 
 
1293
1294
1295
1296
1297
1298
1299
1300
1301
 
 
 
 
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
 
1322
1323
1324
 
 
1325
1326
 
1327
1328
1329
1330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
 
1345
1346
1347
1348
1349
1350
1351
 
 
 
 
1352
1353
1354
1355
1356
1357
 
1358
1359
 
 
 
 
 
1360
1361
 
 
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
 
 
 
 
 
 
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
...
1397
1398
1399
 
 
1400
1401
1402
1403
1404
...
1407
1408
1409
 
 
 
 
 
 
 
 
 
1410
1411
1412
1413
1414
1415
1416
 
1417
1418
1419
1420
...
1425
1426
1427
 
 
 
 
 
1428
1429
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
 
 
 
 
 
 
1463
1464
1465
1466
1467
1468
1469
1470
 
1471
1472
1473
 
1474
1475
1476
1477
1478
1479
1480
 
 
1481
1482
1483
 
1484
1485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1486
1487
1488
1489
1490
1491
 
 
1492
1493
1494
 
 
1495
1496
1497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
 
1508
1509
1510
1511
...
1516
1517
1518
 
1519
1520
1521
...
1533
1534
1535
 
 
1536
1537
1538
1539
1540
1541
1542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
 
 
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
...
1595
1596
1597
 
 
 
 
1598
1599
1600
1601
1602
1603
1604
 
1605
1606
1607
1608
1609
1610
 
1611
1612
1613
1614
1615
1616
 
1617
1618
1619
1620
1621
1622
 
1623
1624
1625
1626
 
1627
1628
1629
1630
1631
1632
 
 
 
 
 
1633
1634
1635
1636
1637
 
1638
1639
 
1640
1641
1642
1643
1644
1645
 
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
...
1683
1684
1685
1686
1687
1688
1689
1690
 
1691
1692
1693
1694
1695
 
1696
1697
1698
1699
1700
1701
1702
 
1703
1704
1705
1706
1707
1708
 
 
 
 
 
 
 
 
 
 
 
 
 
1709
1710
1711
 
 
 
 
 
 
 
 
 
 
 
1712
1713
 
 
1714
1715
1716
1717
1718
...
1723
1724
1725
 
1726
1727
 
1728
1729
1730
1731
1732
 
1733
 
 
 
1734
1735
1736
1737
 
1738
1739
1740
0
@@ -15,11 +15,9 @@
0
  *
0
  * Each child of the root window is called a client, except windows which have
0
  * set the override_redirect flag.  Clients are organized in a global
0
- * doubly-linked client list, the focus history is remembered through a global
0
- * stack list. Each client contains an array of Bools of the same size as the
0
- * global tags array to indicate the tags of a client.  For each client dwm
0
- * creates a small title window, which is resized whenever the (_NET_)WM_NAME
0
- * properties are updated or the client is moved/resized.
0
+ * linked client list, the focus history is remembered through a global
0
+ * stack list. Each client contains a bit array to indicate the tags of a
0
+ * client.
0
  *
0
  * Keys and tagging rules are organized as arrays and defined in config.h.
0
  *
0
@@ -35,40 +33,64 @@
0
 #include <sys/select.h>
0
 #include <sys/types.h>
0
 #include <sys/wait.h>
0
-#include <regex.h>
0
 #include <X11/cursorfont.h>
0
 #include <X11/keysym.h>
0
 #include <X11/Xatom.h>
0
 #include <X11/Xlib.h>
0
 #include <X11/Xproto.h>
0
 #include <X11/Xutil.h>
0
+#ifdef XINERAMA
0
+#include <X11/extensions/Xinerama.h>
0
+#endif
0
 
0
 /* macros */
0
-#define BUTTONMASK    (ButtonPressMask | ButtonReleaseMask)
0
-#define CLEANMASK(mask)    (mask & ~(numlockmask | LockMask))
0
-#define MOUSEMASK    (BUTTONMASK | PointerMotionMask)
0
+#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
0
+#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
0
+#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
0
+#define ISVISIBLE(x)            (x->tags & tagset[seltags])
0
+#define LENGTH(x)               (sizeof x / sizeof x[0])
0
+#define MAX(a, b)               ((a) > (b) ? (a) : (b))
0
+#define MIN(a, b)               ((a) < (b) ? (a) : (b))
0
+#define MAXTAGLEN               16
0
+#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
0
+#define WIDTH(x)                ((x)->w + 2 * (x)->bw)
0
+#define HEIGHT(x)               ((x)->h + 2 * (x)->bw)
0
+#define TAGMASK                 ((int)((1LL << LENGTH(tags)) - 1))
0
+#define TEXTW(x)                (textnw(x, strlen(x)) + dc.font.height)
0
 
0
 /* enums */
0
-enum { BarTop, BarBot, BarOff };      /* bar position */
0
-enum { CurNormal, CurResize, CurMove, CurLast };  /* cursor */
0
-enum { ColBorder, ColFG, ColBG, ColLast };    /* color */
0
-enum { NetSupported, NetWMName, NetLast };    /* EWMH atoms */
0
-enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
0
+enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
0
+enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
0
+enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
0
+enum { WMProtocols, WMDelete, WMState, WMLast };        /* default atoms */
0
+enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
0
+       ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
0
+
0
+typedef union {
0
+  int i;
0
+  unsigned int ui;
0
+  float f;
0
+  void *v;
0
+} Arg;
0
+
0
+typedef struct {
0
+  unsigned int click;
0
+  unsigned int mask;
0
+  unsigned int button;
0
+  void (*func)(const Arg *arg);
0
+  const Arg arg;
0
+} Button;
0
 
0
-/* typedefs */
0
 typedef struct Client Client;
0
 struct Client {
0
   char name[256];
0
+  float mina, maxa;
0
   int x, y, w, h;
0
-  int rx, ry, rw, rh; /* revert geometry */
0
   int basew, baseh, incw, inch, maxw, maxh, minw, minh;
0
-  int minax, maxax, minay, maxay;
0
-  long flags;
0
-  unsigned int border, oldborder;
0
-  Bool isbanned, isfixed, ismax, isfloating, wasfloating;
0
-  Bool *tags;
0
+  int bw, oldbw;
0
+  unsigned int tags;
0
+  Bool isfixed, isfloating, isurgent;
0
   Client *next;
0
-  Client *prev;
0
   Client *snext;
0
   Window win;
0
 };
0
@@ -89,10 +111,10 @@ typedef struct {
0
 } DC; /* draw context */
0
 
0
 typedef struct {
0
-  unsigned long mod;
0
+  unsigned int mod;
0
   KeySym keysym;
0
-  void (*func)(const char *arg);
0
-  const char *arg;
0
+  void (*func)(const Arg *);
0
+  const Arg arg;
0
 } Key;
0
 
0
 typedef struct {
0
@@ -101,191 +123,165 @@ typedef struct {
0
 } Layout;
0
 
0
 typedef struct {
0
-  const char *prop;
0
-  const char *tags;
0
+  const char *class;
0
+  const char *instance;
0
+  const char *title;
0
+  unsigned int tags;
0
   Bool isfloating;
0
 } Rule;
0
 
0
-typedef struct {
0
-  regex_t *propregex;
0
-  regex_t *tagregex;
0
-} Regs;
0
-
0
 /* function declarations */
0
-void applyrules(Client *c);
0
-void arrange(void);
0
-void attach(Client *c);
0
-void attachstack(Client *c);
0
-void ban(Client *c);
0
-void buttonpress(XEvent *e);
0
-void checkotherwm(void);
0
-void cleanup(void);
0
-void compileregs(void);
0
-void configure(Client *c);
0
-void configurenotify(XEvent *e);
0
-void configurerequest(XEvent *e);
0
-void destroynotify(XEvent *e);
0
-void detach(Client *c);
0
-void detachstack(Client *c);
0
-void drawbar(void);
0
-void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
0
-void drawtext(const char *text, unsigned long col[ColLast]);
0
-void *emallocz(unsigned int size);
0
-void enternotify(XEvent *e);
0
-void eprint(const char *errstr, ...);
0
-void expose(XEvent *e);
0
-void floating(void); /* default floating layout */
0
-void focus(Client *c);
0
-void focusnext(const char *arg);
0
-void focusprev(const char *arg);
0
-Client *getclient(Window w);
0
-unsigned long getcolor(const char *colstr);
0
-long getstate(Window w);
0
-Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
0
-void grabbuttons(Client *c, Bool focused);
0
-unsigned int idxoftag(const char *tag);
0
-void initfont(const char *fontstr);
0
-Bool isarrange(void (*func)());
0
-Bool isoccupied(unsigned int t);
0
-Bool isprotodel(Client *c);
0
-Bool isvisible(Client *c);
0
-void keypress(XEvent *e);
0
-void killclient(const char *arg);
0
-void leavenotify(XEvent *e);
0
-void manage(Window w, XWindowAttributes *wa);
0
-void mappingnotify(XEvent *e);
0
-void maprequest(XEvent *e);
0
-void movemouse(Client *c);
0
-Client *nexttiled(Client *c);
0
-void propertynotify(XEvent *e);
0
-void quit(const char *arg);
0
-void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
0
-void resizemouse(Client *c);
0
-void restack(void);
0
-void run(void);
0
-void scan(void);
0
-void setclientstate(Client *c, long state);
0
-void setlayout(const char *arg);
0
-void setmwfact(const char *arg);
0
-void setup(void);
0
-void spawn(const char *arg);
0
-void tag(const char *arg);
0
-unsigned int textnw(const char *text, unsigned int len);
0
-unsigned int textw(const char *text);
0
-void tile(void);
0
-void togglebar(const char *arg);
0
-void togglefloating(const char *arg);
0
-void togglemax(const char *arg);
0
-void toggletag(const char *arg);
0
-void toggleview(const char *arg);
0
-void unban(Client *c);
0
-void unmanage(Client *c);
0
-void unmapnotify(XEvent *e);
0
-void updatebarpos(void);
0
-void updatesizehints(Client *c);
0
-void updatetitle(Client *c);
0
-void view(const char *arg);
0
-void viewprevtag(const char *arg);  /* views previous selected tags */
0
-int xerror(Display *dpy, XErrorEvent *ee);
0
-int xerrordummy(Display *dsply, XErrorEvent *ee);
0
-int xerrorstart(Display *dsply, XErrorEvent *ee);
0
-void zoom(const char *arg);
0
+static void applyrules(Client *c);
0
+static void arrange(void);
0
+static void attach(Client *c);
0
+static void attachstack(Client *c);
0
+static void buttonpress(XEvent *e);
0
+static void checkotherwm(void);
0
+static void cleanup(void);
0
+static void clearurgent(Client *c);
0
+static void configure(Client *c);
0
+static void configurenotify(XEvent *e);
0
+static void configurerequest(XEvent *e);
0
+static void destroynotify(XEvent *e);
0
+static void detach(Client *c);
0
+static void detachstack(Client *c);
0
+static void die(const char *errstr, ...);
0
+static void drawbar(void);
0
+static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
0
+static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
0
+static void enternotify(XEvent *e);
0
+static void expose(XEvent *e);
0
+static void focus(Client *c);
0
+static void focusin(XEvent *e);
0
+static void focusstack(const Arg *arg);
0
+static Client *getclient(Window w);
0
+static unsigned long getcolor(const char *colstr);
0
+static long getstate(Window w);
0
+static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
0
+static void grabbuttons(Client *c, Bool focused);
0
+static void grabkeys(void);
0
+static void initfont(const char *fontstr);
0
+static Bool isprotodel(Client *c);
0
+static void keypress(XEvent *e);
0
+static void killclient(const Arg *arg);
0
+static void manage(Window w, XWindowAttributes *wa);
0
+static void mappingnotify(XEvent *e);
0
+static void maprequest(XEvent *e);
0
+static void monocle(void);
0
+static void movemouse(const Arg *arg);
0
+static Client *nexttiled(Client *c);
0
+static void propertynotify(XEvent *e);
0
+static void quit(const Arg *arg);
0
+static void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
0
+static void resizemouse(const Arg *arg);
0
+static void restack(void);
0
+static void run(void);
0
+static void scan(void);
0
+static void setclientstate(Client *c, long state);
0
+static void setlayout(const Arg *arg);
0
+static void setmfact(const Arg *arg);
0
+static void setup(void);
0
+static void showhide(Client *c);
0
+static void spawn(const Arg *arg);
0
+static void tag(const Arg *arg);
0
+static int textnw(const char *text, unsigned int len);
0
+static void tile(void);
0
+static void togglebar(const Arg *arg);
0
+static void togglefloating(const Arg *arg);
0
+static void toggletag(const Arg *arg);
0
+static void toggleview(const Arg *arg);
0
+static void unmanage(Client *c);
0
+static void unmapnotify(XEvent *e);
0
+static void updatebar(void);
0
+static void updategeom(void);
0
+static void updatenumlockmask(void);
0
+static void updatesizehints(Client *c);
0
+static void updatetitle(Client *c);
0
+static void updatewmhints(Client *c);
0
+static void view(const Arg *arg);
0
+static int xerror(Display *dpy, XErrorEvent *ee);
0
+static int xerrordummy(Display *dpy, XErrorEvent *ee);
0
+static int xerrorstart(Display *dpy, XErrorEvent *ee);
0
+static void zoom(const Arg *arg);
0
 
0
 /* variables */
0
-char stext[256];
0
-double mwfact;
0
-int screen, sx, sy, sw, sh, wax, way, waw, wah;
0
-int (*xerrorxlib)(Display *, XErrorEvent *);
0
-unsigned int bh, bpos;
0
-unsigned int blw = 0;
0
-unsigned int ltidx = 0; /* default */
0
-unsigned int nlayouts = 0;
0
-unsigned int nrules = 0;
0
-unsigned int numlockmask = 0;
0
-void (*handler[LASTEvent]) (XEvent *) = {
0
+static char stext[256];
0
+static int screen;
0
+static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */ 
0
+static int by, bh, blw;    /* bar geometry y, height and layout symbol width */
0
+static int wx, wy, ww, wh; /* window area geometry x, y, width, height, bar excluded */
0
+static unsigned int seltags = 0, sellt = 0;
0
+static int (*xerrorxlib)(Display *, XErrorEvent *);
0
+static unsigned int numlockmask = 0;
0
+static void (*handler[LASTEvent]) (XEvent *) = {
0
   [ButtonPress] = buttonpress,
0
   [ConfigureRequest] = configurerequest,
0
   [ConfigureNotify] = configurenotify,
0
   [DestroyNotify] = destroynotify,
0
   [EnterNotify] = enternotify,
0
-  [LeaveNotify] = leavenotify,
0
   [Expose] = expose,
0
+  [FocusIn] = focusin,
0
   [KeyPress] = keypress,
0
   [MappingNotify] = mappingnotify,
0
   [MapRequest] = maprequest,
0
   [PropertyNotify] = propertynotify,
0
   [UnmapNotify] = unmapnotify
0
 };
0
-Atom wmatom[WMLast], netatom[NetLast];
0
-Bool otherwm, readin;
0
-Bool running = True;
0
-Bool selscreen = True;
0
-Client *clients = NULL;
0
-Client *sel = NULL;
0
-Client *stack = NULL;
0
-Cursor cursor[CurLast];
0
-Display *dpy;
0
-DC dc = {0};
0
-Window barwin, root;
0
-Regs *regs = NULL;
0
-
0
+static Atom wmatom[WMLast], netatom[NetLast];
0
+static Bool otherwm;
0
+static Bool running = True;
0
+static Client *clients = NULL;
0
+static Client *sel = NULL;
0
+static Client *stack = NULL;
0
+static Cursor cursor[CurLast];
0
+static Display *dpy;
0
+static DC dc;
0
+static Layout *lt[] = { NULL, NULL };
0
+static Window root, barwin;
0
 /* configuration, allows nested code to access above variables */
0
 #include "config.h"
0
 
0
-#define NTAGS (sizeof tags / sizeof tags[0])
0
-Bool seltags[NTAGS] = {[0] = True};
0
-Bool prevtags[NTAGS] = {[0] = True};
0
+/* compile-time check if all tags fit into an unsigned int bit array. */
0
+struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
0
 
0
 /* function implementations */
0
 void
0
 applyrules(Client *c) {
0
-  static char buf[512];
0
-  unsigned int i, j;
0
-  regmatch_t tmp;
0
-  Bool matched = False;
0
+  unsigned int i;
0
+  Rule *r;
0
   XClassHint ch = { 0 };
0
 
0
   /* rule matching */
0
-  XGetClassHint(dpy, c->win, &ch);
0
-  snprintf(buf, sizeof buf, "%s:%s:%s",
0
-      ch.res_class ? ch.res_class : "",
0
-      ch.res_name ? ch.res_name : "", c->name);
0
-  for(i = 0; i < nrules; i++)
0
-    if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) {
0
-      c->isfloating = rules[i].isfloating;
0
-      for(j = 0; regs[i].tagregex && j < NTAGS; j++) {
0
-        if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
0
-          matched = True;
0
-          c->tags[j] = True;
0
-        }
0
+  if(XGetClassHint(dpy, c->win, &ch)) {
0
+    for(i = 0; i < LENGTH(rules); i++) {
0
+      r = &rules[i];
0
+      if((!r->title || strstr(c->name, r->title))
0
+      && (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
0
+      && (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
0
+        c->isfloating = r->isfloating;
0
+        c->tags |= r->tags & TAGMASK;
0
       }
0
     }
0
-  if(ch.res_class)
0
-    XFree(ch.res_class);
0
-  if(ch.res_name)
0
-    XFree(ch.res_name);
0
-  if(!matched)
0
-    memcpy(c->tags, seltags, sizeof seltags);
0
+    if(ch.res_class)
0
+      XFree(ch.res_class);
0
+    if(ch.res_name)
0
+      XFree(ch.res_name);
0
+  }
0
+  if(!c->tags)
0
+    c->tags = tagset[seltags];
0
 }
0
 
0
 void
0
 arrange(void) {
0
-  Client *c;
0
-
0
-  for(c = clients; c; c = c->next)
0
-    if(isvisible(c))
0
-      unban(c);
0
-    else
0
-      ban(c);
0
-  layouts[ltidx].arrange();
0
+  showhide(stack);
0
   focus(NULL);
0
+  if(lt[sellt]->arrange)
0
+    lt[sellt]->arrange();
0
   restack();
0
 }
0
 
0
 void
0
 attach(Client *c) {
0
-  if(clients)
0
-    clients->prev = c;
0
   c->next = clients;
0
   clients = c;
0
 }
0
@@ -297,92 +293,62 @@ attachstack(Client *c) {
0
 }
0
 
0
 void
0
-ban(Client *c) {
0
-  if(c->isbanned)
0
-    return;
0
-  XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
0
-  c->isbanned = True;
0
-}
0
-
0
-void
0
 buttonpress(XEvent *e) {
0
-  unsigned int i, x;
0
+  unsigned int i, x, click;
0
+  Arg arg = {0};
0
   Client *c;
0
   XButtonPressedEvent *ev = &e->xbutton;
0
 
0
-  if(barwin == ev->window) {
0
-    x = 0;
0
-    for(i = 0; i < NTAGS; i++) {
0
-      x += textw(tags[i]);
0
-      if(ev->x < x) {
0
-        if(ev->button == Button1) {
0
-          if(ev->state & MODKEY)
0
-            tag(tags[i]);
0
-          else
0
-            view(tags[i]);
0
-        }
0
-        else if(ev->button == Button3) {
0
-          if(ev->state & MODKEY)
0
-            toggletag(tags[i]);
0
-          else
0
-            toggleview(tags[i]);
0
-        }
0
-        return;
0
-      }
0
+  click = ClkRootWin;
0
+  if(ev->window == barwin) {
0
+    i = x = 0;
0
+    do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags));
0
+    if(i < LENGTH(tags)) {
0
+      click = ClkTagBar;
0
+      arg.ui = 1 << i;
0
     }
0
-    if((ev->x < x + blw) && ev->button == Button1)
0
-      setlayout(NULL);
0
+    else if(ev->x < x + blw)
0
+      click = ClkLtSymbol;
0
+    else if(ev->x > wx + ww - TEXTW(stext))
0
+      click = ClkStatusText;
0
+    else
0
+      click = ClkWinTitle;
0
   }
0
   else if((c = getclient(ev->window))) {
0
     focus(c);
0
-    if(CLEANMASK(ev->state) != MODKEY)
0
-      return;
0
-    if(ev->button == Button1) {
0
-      if(isarrange(floating) || c->isfloating)
0
-        restack();
0
-      else
0
-        togglefloating(NULL);
0
-      movemouse(c);
0
-    }
0
-    else if(ev->button == Button2) {
0
-      if((ISTILE) && !c->isfixed && c->isfloating)
0
-        togglefloating(NULL);
0
-      else
0
-        zoom(NULL);
0
-    }
0
-    else if(ev->button == Button3 && !c->isfixed) {
0
-      if(isarrange(floating) || c->isfloating)
0
-        restack();
0
-      else
0
-        togglefloating(NULL);
0
-      resizemouse(c);
0
-    }
0
+    click = ClkClientWin;
0
   }
0
+
0
+  for(i = 0; i < LENGTH(buttons); i++)
0
+    if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
0
+       && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
0
+      buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
0
 }
0
 
0
 void
0
 checkotherwm(void) {
0
   otherwm = False;
0
-  XSetErrorHandler(xerrorstart);
0
+  xerrorxlib = XSetErrorHandler(xerrorstart);
0
 
0
   /* this causes an error if some other window manager is running */
0
-  XSelectInput(dpy, root, SubstructureRedirectMask);
0
+  XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
0
   XSync(dpy, False);
0
   if(otherwm)
0
-    eprint("dwm: another window manager is already running\n");
0
-  XSync(dpy, False);
0
-  XSetErrorHandler(NULL);
0
-  xerrorxlib = XSetErrorHandler(xerror);
0
+    die("dwm: another window manager is already running\n");
0
+  XSetErrorHandler(xerror);
0
   XSync(dpy, False);
0
 }
0
 
0
 void
0
 cleanup(void) {
0
+  Arg a = {.ui = ~0};
0
+  Layout foo = { "", NULL };
0
+
0
   close(STDIN_FILENO);
0
-  while(stack) {
0
-    unban(stack);
0
+  view(&a);
0
+  lt[sellt] = &foo;
0
+  while(stack)
0
     unmanage(stack);
0
-  }
0
   if(dc.font.set)
0
     XFreeFontSet(dpy, dc.font.set);
0
   else
0
@@ -390,39 +356,24 @@ cleanup(void) {
0
   XUngrabKey(dpy, AnyKey, AnyModifier, root);
0
   XFreePixmap(dpy, dc.drawable);
0
   XFreeGC(dpy, dc.gc);
0
-  XDestroyWindow(dpy, barwin);
0
   XFreeCursor(dpy, cursor[CurNormal]);
0
   XFreeCursor(dpy, cursor[CurResize]);
0
   XFreeCursor(dpy, cursor[CurMove]);
0
-  XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
0
+  XDestroyWindow(dpy, barwin);
0
   XSync(dpy, False);
0
+  XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
0
 }
0
 
0
 void
0
-compileregs(void) {
0
-  unsigned int i;
0
-  regex_t *reg;
0
+clearurgent(Client *c) {
0
+  XWMHints *wmh;
0
 
0
-  if(regs)
0
+  c->isurgent = False;
0
+  if(!(wmh = XGetWMHints(dpy, c->win)))
0
     return;
0
-  nrules = sizeof rules / sizeof rules[0];
0
-  regs = emallocz(nrules * sizeof(Regs));
0
-  for(i = 0; i < nrules; i++) {
0
-    if(rules[i].prop) {
0
-      reg = emallocz(sizeof(regex_t));
0
-      if(regcomp(reg, rules[i].prop, REG_EXTENDED))
0
-        free(reg);
0
-      else
0
-        regs[i].propregex = reg;
0
-    }
0
-    if(rules[i].tags) {
0
-      reg = emallocz(sizeof(regex_t));
0
-      if(regcomp(reg, rules[i].tags, REG_EXTENDED))
0
-        free(reg);
0
-      else
0
-        regs[i].tagregex = reg;
0
-    }
0
-  }
0
+  wmh->flags &= ~XUrgencyHint;
0
+  XSetWMHints(dpy, c->win, wmh);
0
+  XFree(wmh);
0
 }
0
 
0
 void
0
@@ -437,7 +388,7 @@ configure(Client *c) {
0
   ce.y = c->y;
0
   ce.width = c->w;
0
   ce.height = c->h;
0
-  ce.border_width = c->border;
0
+  ce.border_width = c->bw;
0
   ce.above = None;
0
   ce.override_redirect = False;
0
   XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
0
@@ -450,10 +401,8 @@ configurenotify(XEvent *e) {
0
   if(ev->window == root && (ev->width != sw || ev->height != sh)) {
0
     sw = ev->width;
0
     sh = ev->height;
0
-    XFreePixmap(dpy, dc.drawable);
0
-    dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
0
-    XResizeWindow(dpy, barwin, sw, bh);
0
-    updatebarpos();
0
+    updategeom();
0
+    updatebar();
0
     arrange();
0
   }
0
 }
0
@@ -465,26 +414,24 @@ configurerequest(XEvent *e) {
0
   XWindowChanges wc;
0
 
0
   if((c = getclient(ev->window))) {
0
-    c->ismax = False;
0
     if(ev->value_mask & CWBorderWidth)
0
-      c->border = ev->border_width;
0
-    if(c->isfixed || c->isfloating || isarrange(floating)) {
0
+      c->bw = ev->border_width;
0
+    else if(c->isfloating || !lt[sellt]->arrange) {
0
       if(ev->value_mask & CWX)
0
-        c->x = ev->x;
0
+        c->x = sx + ev->x;
0
       if(ev->value_mask & CWY)
0
-        c->y = ev->y;
0
+        c->y = sy + ev->y;
0
       if(ev->value_mask & CWWidth)
0
         c->w = ev->width;
0
       if(ev->value_mask & CWHeight)
0
         c->h = ev->height;
0
-      if((c->x + c->w) > sw && c->isfloating)
0
-        c->x = sw / 2 - c->w / 2; /* center in x direction */
0
-      if((c->y + c->h) > sh && c->isfloating)
0
-        c->y = sh / 2 - c->h / 2; /* center in y direction */
0
-      if((ev->value_mask & (CWX | CWY))
0
-      && !(ev->value_mask & (CWWidth | CWHeight)))
0
+      if((c->x - sx + c->w) > sw && c->isfloating)
0
+        c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
0
+      if((c->y - sy + c->h) > sh && c->isfloating)
0
+        c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
0
+      if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
0
         configure(c);
0
-      if(isvisible(c))
0
+      if(ISVISIBLE(c))
0
         XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
0
     }
0
     else
0
@@ -514,70 +461,85 @@ destroynotify(XEvent *e) {
0
 
0
 void
0
 detach(Client *c) {
0
-  if(c->prev)
0
-    c->prev->next = c->next;
0
-  if(c->next)
0
-    c->next->prev = c->prev;
0
-  if(c == clients)
0
-    clients = c->next;
0
-  c->next = c->prev = NULL;
0
+  Client **tc;
0
+
0
+  for(tc = &clients; *tc && *tc != c; tc = &(*tc)->next);
0
+  *tc = c->next;
0
 }
0
 
0
 void
0
 detachstack(Client *c) {
0
   Client **tc;
0
 
0
-  for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
0
+  for(tc = &stack; *tc && *tc != c; tc = &(*tc)->snext);
0
   *tc = c->snext;
0
 }
0
 
0
 void
0
+die(const char *errstr, ...) {
0
+  va_list ap;
0
+
0
+  va_start(ap, errstr);
0
+  vfprintf(stderr, errstr, ap);
0
+  va_end(ap);
0
+  exit(EXIT_FAILURE);
0
+}
0
+
0
+void
0
 drawbar(void) {
0
-  int i, x;
0
-
0
-  dc.x = dc.y = 0;
0
-  for(i = 0; i < NTAGS; i++) {
0
-    dc.w = textw(tags[i]);
0
-    if(seltags[i]) {
0
-      drawtext(tags[i], dc.sel);
0
-      drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel);
0
-    }
0
-    else {
0
-      drawtext(tags[i], dc.norm);
0
-      drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm);
0
-    }
0
+  int x;
0
+  unsigned int i, occ = 0, urg = 0;
0
+  unsigned long *col;
0
+  Client *c;
0
+
0
+  for(c = clients; c; c = c->next) {
0
+    occ |= c->tags;
0
+    if(c->isurgent)
0
+      urg |= c->tags;
0
+  }
0
+
0
+  dc.x = 0;
0
+  for(i = 0; i < LENGTH(tags); i++) {
0
+    dc.w = TEXTW(tags[i]);
0
+    col = tagset[seltags] & 1 << i ? dc.sel : dc.norm;
0
+    drawtext(tags[i], col, urg & 1 << i);
0
+    drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col);
0
     dc.x += dc.w;
0
   }
0
-  dc.w = blw;
0
-  drawtext(layouts[ltidx].symbol, dc.norm);
0
-  x = dc.x + dc.w;
0
-  dc.w = textw(stext);
0
-  dc.x = sw - dc.w;
0
+  if(blw > 0) {
0
+    dc.w = blw;
0
+    drawtext(lt[sellt]->symbol, dc.norm, False);
0
+    x = dc.x + dc.w;
0
+  }
0
+  else
0
+    x = dc.x;
0
+  dc.w = TEXTW(stext);
0
+  dc.x = ww - dc.w;
0
   if(dc.x < x) {
0
     dc.x = x;
0
-    dc.w = sw - x;
0
+    dc.w = ww - x;
0
   }
0
-  drawtext(stext, dc.norm);
0
+  drawtext(stext, dc.norm, False);
0
   if((dc.w = dc.x - x) > bh) {
0
     dc.x = x;
0
     if(sel) {
0
-      drawtext(sel->name, dc.sel);
0
-      drawsquare(sel->ismax, sel->isfloating, dc.sel);
0
+      drawtext(sel->name, dc.sel, False);
0
+      drawsquare(sel->isfixed, sel->isfloating, False, dc.sel);
0
     }
0
     else
0
-      drawtext(NULL, dc.norm);
0
+      drawtext(NULL, dc.norm, False);
0
   }
0
-  XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
0
+  XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0);
0
   XSync(dpy, False);
0
 }
0
 
0
 void
0
-drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
0
+drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
0
   int x;
0
   XGCValues gcv;
0
   XRectangle r = { dc.x, dc.y, dc.w, dc.h };
0
 
0
-  gcv.foreground = col[ColFG];
0
+  gcv.foreground = col[invert ? ColBG : ColFG];
0
   XChangeGC(dpy, dc.gc, GCForeground, &gcv);
0
   x = (dc.font.ascent + dc.font.descent + 2) / 4;
0
   r.x = dc.x + 1;
0
@@ -593,148 +555,104 @@ drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
0
 }
0
 
0
 void
0
-drawtext(const char *text, unsigned long col[ColLast]) {
0
-  int x, y, w, h;
0
-  static char buf[256];
0
-  unsigned int len, olen;
0
+drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
0
+  char buf[256];
0
+  int i, x, y, h, len, olen;
0
   XRectangle r = { dc.x, dc.y, dc.w, dc.h };
0
 
0
-  XSetForeground(dpy, dc.gc, col[ColBG]);
0
+  XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
0
   XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
0
   if(!text)
0
     return;
0
-  w = 0;
0
-  olen = len = strlen(text);
0
-  if(len >= sizeof buf)
0
-    len = sizeof buf - 1;
0
-  memcpy(buf, text, len);
0
-  buf[len] = 0;
0
+  olen = strlen(text);
0
   h = dc.font.ascent + dc.font.descent;
0
   y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
0
   x = dc.x + (h / 2);
0
   /* shorten text if necessary */
0
-  while(len && (w = textnw(buf, len)) > dc.w - h)
0
-    buf[--len] = 0;
0
-  if(len < olen) {
0
-    if(len > 1)
0
-      buf[len - 1] = '.';
0
-    if(len > 2)
0
-      buf[len - 2] = '.';
0
-    if(len > 3)
0
-      buf[len - 3] = '.';
0
-  }
0
-  if(w > dc.w)
0
-    return; /* too long */
0
-  XSetForeground(dpy, dc.gc, col[ColFG]);
0
+  for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
0
+  if(!len)
0
+    return;
0
+  memcpy(buf, text, len);
0
+  if(len < olen)
0
+    for(i = len; i && i > len - 3; buf[--i] = '.');
0
+  XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
0
   if(dc.font.set)
0
     XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
0
   else
0
     XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
0
 }
0
 
0
-void *
0
-emallocz(unsigned int size) {
0
-  void *res = calloc(1, size);
0
-
0
-  if(!res)
0
-    eprint("fatal: could not malloc() %u bytes\n", size);
0
-  return res;
0
-}
0
-
0
 void
0
 enternotify(XEvent *e) {
0
   Client *c;
0
   XCrossingEvent *ev = &e->xcrossing;
0
 
0
-  if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
0
+  if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
0
     return;
0
   if((c = getclient(ev->window)))
0
     focus(c);
0
-  else if(ev->window == root) {
0
-    selscreen = True;
0
+  else
0
     focus(NULL);
0
-  }
0
-}
0
-
0
-void
0
-eprint(const char *errstr, ...) {
0
-  va_list ap;
0
-
0
-  va_start(ap, errstr);
0
-  vfprintf(stderr, errstr, ap);
0
-  va_end(ap);
0
-  exit(EXIT_FAILURE);
0
 }
0
 
0
 void
0
 expose(XEvent *e) {
0
   XExposeEvent *ev = &e->xexpose;
0
 
0
-  if(ev->count == 0) {
0
-    if(barwin == ev->window)
0
-      drawbar();
0
-  }
0
-}
0
-
0
-void
0
-floating(void) { /* default floating layout */
0
-  Client *c;
0
-
0
-  for(c = clients; c; c = c->next)
0
-    if(isvisible(c))
0
-      resize(c, c->x, c->y, c->w, c->h, True);
0
+  if(ev->count == 0 && (ev->window == barwin))
0
+    drawbar();
0
 }
0
 
0
 void
0
 focus(Client *c) {
0
-  if((!c && selscreen) || (c && !isvisible(c)))
0
-    for(c = stack; c && !isvisible(c); c = c->snext);
0
+  if(!c || !ISVISIBLE(c))
0
+    for(c = stack; c && !ISVISIBLE(c); c = c->snext);
0
   if(sel && sel != c) {
0
     grabbuttons(sel, False);
0
     XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
0
   }
0
   if(c) {
0
+    if(c->isurgent)
0
+      clearurgent(c);
0
     detachstack(c);
0
     attachstack(c);
0
     grabbuttons(c, True);
0
-  }
0
-  sel = c;
0
-  drawbar();
0
-  if(!selscreen)
0
-    return;
0
-  if(c) {
0
     XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
0
     XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
0
   }
0
   else
0
     XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
0
+  sel = c;
0
+  drawbar();
0
 }
0
 
0
 void
0
-focusnext(const char *arg) {
0
-  Client *c;
0
+focusin(XEvent *e) { /* there are some broken focus acquiring clients */
0
+  XFocusChangeEvent *ev = &e->xfocus;
0
 
0
-  if(!sel)
0
-    return;
0
-  for(c = sel->next; c && !isvisible(c); c = c->next);
0
-  if(!c)
0
-    for(c = clients; c && !isvisible(c); c = c->next);
0
-  if(c) {
0
-    focus(c);
0
-    restack();
0
-  }
0
+  if(sel && ev->window != sel->win)
0
+    XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
0
 }
0
 
0
 void
0
-focusprev(const char *arg) {
0
-  Client *c;
0
+focusstack(const Arg *arg) {
0
+  Client *c = NULL, *i;
0
 
0
   if(!sel)
0
     return;
0
-  for(c = sel->prev; c && !isvisible(c); c = c->prev);
0
-  if(!c) {
0
-    for(c = clients; c && c->next; c = c->next);
0
-    for(; c && !isvisible(c); c = c->prev);
0
+  if (arg->i > 0) {
0
+    for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
0
+    if(!c)
0
+      for(c = clients; c && !ISVISIBLE(c); c = c->next);
0
+  }
0
+  else {
0
+    for(i = clients; i != sel; i = i->next)
0
+      if(ISVISIBLE(i))
0
+        c = i;
0
+    if(!c)
0
+      for(; i; i = i->next)
0
+        if(ISVISIBLE(i))
0
+          c = i;
0
   }
0
   if(c) {
0
     focus(c);
0
@@ -756,7 +674,7 @@ getcolor(const char *colstr) {
0
   XColor color;
0
 
0
   if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
0
-    eprint("error, cannot allocate color '%s'\n", colstr);
0
+    die("error, cannot allocate color '%s'\n", colstr);
0
   return color.pixel;
0
 }
0
 
0
@@ -794,8 +712,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
0
     strncpy(text, (char *)name.value, size - 1);
0
   else {
0
     if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
0
-    && n > 0 && *list)
0
-    {
0
+    && n > 0 && *list) {
0
       strncpy(text, *list, size - 1);
0
       XFreeStringList(list);
0
     }
0
@@ -807,47 +724,38 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
0
 
0
 void
0
 grabbuttons(Client *c, Bool focused) {
0
-  XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
0
-
0
-  if(focused) {
0
-    XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-
0
-    XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-
0
-    XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
-    XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
+  updatenumlockmask();
0
+  {
0
+    unsigned int i, j;
0
+    unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
0
+    XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
0
+    if(focused) {
0
+      for(i = 0; i < LENGTH(buttons); i++)
0
+        if(buttons[i].click == ClkClientWin)
0
+          for(j = 0; j < LENGTH(modifiers); j++)
0
+            XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
0
+    } else
0
+      XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
0
+                  BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
0
   }
0
-  else
0
-    XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
0
-        GrabModeAsync, GrabModeSync, None, None);
0
 }
0
 
0
-unsigned int
0
-idxoftag(const char *tag) {
0
-  unsigned int i;
0
+void
0
+grabkeys(void) {
0
+  updatenumlockmask();
0
+  { /* grab keys */
0
+    unsigned int i, j;
0
+    unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
0
+    KeyCode code;
0
 
0
-  for(i = 0; (i < NTAGS) && (tags[i] != tag); i++);
0
-  return (i < NTAGS) ? i : 0;
0
+    XUngrabKey(dpy, AnyKey, AnyModifier, root);
0
+    for(i = 0; i < LENGTH(keys); i++) {
0
+      if((code = XKeysymToKeycode(dpy, keys[i].keysym)))
0
+        for(j = 0; j < LENGTH(modifiers); j++)
0
+          XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
0
+             True, GrabModeAsync, GrabModeAsync);
0
+    }
0
+  }
0
 }
0
 
0
 void
0
@@ -856,8 +764,6 @@ initfont(const char *fontstr) {
0
   int i, n;
0
 
0
   missing = NULL;
0
-  if(dc.font.set)
0
-    XFreeFontSet(dpy, dc.font.set);
0
   dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
0
   if(missing) {
0
     while(n--)
0
@@ -872,20 +778,15 @@ initfont(const char *fontstr) {
0
     font_extents = XExtentsOfFontSet(dc.font.set);
0
     n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
0
     for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
0
-      if(dc.font.ascent < (*xfonts)->ascent)
0
-        dc.font.ascent = (*xfonts)->ascent;
0
-      if(dc.font.descent < (*xfonts)->descent)
0
-        dc.font.descent = (*xfonts)->descent;
0
+      dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
0
+      dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
0
       xfonts++;
0
     }
0
   }
0
   else {
0
-    if(dc.font.xfont)
0
-      XFreeFont(dpy, dc.font.xfont);
0
-    dc.font.xfont = NULL;
0
     if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
0
     && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
0
-      eprint("error, cannot load font: '%s'\n", fontstr);
0
+      die("error, cannot load font: '%s'\n", fontstr);
0
     dc.font.ascent = dc.font.xfont->ascent;
0
     dc.font.descent = dc.font.xfont->descent;
0
   }
0
@@ -893,22 +794,6 @@ initfont(const char *fontstr) {
0
 }
0
 
0
 Bool
0
-isarrange(void (*func)())
0
-{
0
-  return func == layouts[ltidx].arrange;
0
-}
0
-
0
-Bool
0
-isoccupied(unsigned int t) {
0
-  Client *c;
0
-
0
-  for(c = clients; c; c = c->next)
0
-    if(c->tags[t])
0
-      return True;
0
-  return False;
0
-}
0
-
0
-Bool
0
 isprotodel(Client *c) {
0
   int i, n;
0
   Atom *protocols;
0
@@ -923,53 +808,23 @@ isprotodel(Client *c) {
0
   return ret;
0
 }
0
 
0
-Bool
0
-isvisible(Client *c) {
0
-  unsigned int i;
0
-
0
-  for(i = 0; i < NTAGS; i++)
0
-    if(c->tags[i] && seltags[i])
0
-      return True;
0
-  return False;
0
-}
0
-
0
 void
0
 keypress(XEvent *e) {
0
-  KEYS
0
-  unsigned int len = sizeof keys / sizeof keys[0];
0
   unsigned int i;
0
-  KeyCode code;
0
   KeySym keysym;
0
   XKeyEvent *ev;
0
 
0
-  if(!e) { /* grabkeys */
0
-    XUngrabKey(dpy, AnyKey, AnyModifier, root);
0
-    for(i = 0; i < len; i++) {
0
-      code = XKeysymToKeycode(dpy, keys[i].keysym);
0
-      XGrabKey(dpy, code, keys[i].mod, root, True,
0
-          GrabModeAsync, GrabModeAsync);
0
-      XGrabKey(dpy, code, keys[i].mod | LockMask, root, True,
0
-          GrabModeAsync, GrabModeAsync);
0
-      XGrabKey(dpy, code, keys[i].mod | numlockmask, root, True,
0
-          GrabModeAsync, GrabModeAsync);
0
-      XGrabKey(dpy, code, keys[i].mod | numlockmask | LockMask, root, True,
0
-          GrabModeAsync, GrabModeAsync);
0
-    }
0
-    return;
0
-  }
0
   ev = &e->xkey;
0
   keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
0
-  for(i = 0; i < len; i++)
0
+  for(i = 0; i < LENGTH(keys); i++)
0
     if(keysym == keys[i].keysym
0
-    && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state))
0
-    {
0
-      if(keys[i].func)
0
-        keys[i].func(keys[i].arg);
0
-    }
0
+       && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
0
+       && keys[i].func)
0
+      keys[i].func(&(keys[i].arg));
0
 }
0
 
0
 void
0
-killclient(const char *arg) {
0
+killclient(const Arg *arg) {
0
   XEvent ev;
0
 
0
   if(!sel)
0
@@ -988,66 +843,60 @@ killclient(const char *arg) {
0
 }
0
 
0
 void
0
-leavenotify(XEvent *e) {
0
-  XCrossingEvent *ev = &e->xcrossing;
0
-
0
-  if((ev->window == root) && !ev->same_screen) {
0
-    selscreen = False;
0
-    focus(NULL);
0
-  }
0
-}
0
-
0
-void
0
 manage(Window w, XWindowAttributes *wa) {
0
+  static Client cz;
0
   Client *c, *t = NULL;
0
-  Window trans;
0
-  Status rettrans;
0
+  Window trans = None;
0
   XWindowChanges wc;
0
 
0
-  c = emallocz(sizeof(Client));
0
-  c->tags = emallocz(sizeof seltags);
0
+  if(!(c = malloc(sizeof(Client))))
0
+    die("fatal: could not malloc() %u bytes\n", sizeof(Client));
0
+  *c = cz;
0
   c->win = w;
0
+
0
+  /* geometry */
0
   c->x = wa->x;
0
   c->y = wa->y;
0
   c->w = wa->width;
0
   c->h = wa->height;
0
-  c->oldborder = wa->border_width;
0
+  c->oldbw = wa->border_width;
0
   if(c->w == sw && c->h == sh) {
0
     c->x = sx;
0
     c->y = sy;
0
-    c->border = wa->border_width;
0
+    c->bw = 0;
0
   }
0
   else {
0
-    if(c->x + c->w + 2 * c->border > wax + waw)
0
-      c->x = wax + waw - c->w - 2 * c->border;
0
-    if(c->y + c->h + 2 * c->border > way + wah)
0
-      c->y = way + wah - c->h - 2 * c->border;
0
-    if(c->x < wax)
0
-      c->x = wax;
0
-    if(c->y < way)
0
-      c->y = way;
0
-    c->border = BORDERPX;
0
+    if(c->x + WIDTH(c) > sx + sw)
0
+      c->x = sx + sw - WIDTH(c);
0
+    if(c->y + HEIGHT(c) > sy + sh)
0
+      c->y = sy + sh - HEIGHT(c);
0
+    c->x = MAX(c->x, sx);
0
+    /* only fix client y-offset, if the client center might cover the bar */
0
+    c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy);
0
+    c->bw = borderpx;
0
   }
0
-  wc.border_width = c->border;
0
+
0
+  wc.border_width = c->bw;
0
   XConfigureWindow(dpy, w, CWBorderWidth, &wc);
0
   XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
0
   configure(c); /* propagates border_width, if size doesn't change */
0
   updatesizehints(c);
0
-  XSelectInput(dpy, w,
0
-    StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
0
+  XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
0
   grabbuttons(c, False);
0
   updatetitle(c);
0
-  if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
0
-    for(t = clients; t && t->win != trans; t = t->next);
0
+  if(XGetTransientForHint(dpy, w, &trans))
0
+    t = getclient(trans);
0
   if(t)
0
-    memcpy(c->tags, t->tags, sizeof seltags);
0
-  applyrules(c);
0
+    c->tags = t->tags;
0
+  else
0
+    applyrules(c);
0
   if(!c->isfloating)
0
-    c->isfloating = (rettrans == Success) || c->isfixed;
0
+    c->isfloating = trans != None || c->isfixed;
0
+  if(c->isfloating)
0
+    XRaiseWindow(dpy, c->win);
0
   attach(c);
0
   attachstack(c);
0
-  XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
0
-  ban(c);
0
+  XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
0
   XMapWindow(dpy, c->win);
0
   setclientstate(c, NormalState);
0
   arrange();
0
@@ -1059,7 +908,7 @@ mappingnotify(XEvent *e) {
0
 
0
   XRefreshKeyboardMapping(ev);
0
   if(ev->request == MappingKeyboard)
0
-    keypress(NULL);
0
+    grabkeys();
0
 }
0
 
0
 void
0
@@ -1076,51 +925,70 @@ maprequest(XEvent *e) {
0
 }
0
 
0
 void
0
-movemouse(Client *c) {
0
-  int x1, y1, ocx, ocy, di, nx, ny;
0
+monocle(void) {
0
+  Client *c;
0
+
0
+  for(c = nexttiled(clients); c; c = nexttiled(c->next))
0
+    resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
0
+}
0
+
0
+void
0
+movemouse(const Arg *arg) {
0
+  int x, y, ocx, ocy, di, nx, ny;
0
   unsigned int dui;
0
+  Client *c;
0
   Window dummy;
0
   XEvent ev;
0
 
0
-  ocx = nx = c->x;
0
-  ocy = ny = c->y;
0
+  if(!(c = sel))
0
+    return;
0
+  restack();
0
+  ocx = c->x;
0
+  ocy = c->y;
0
   if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
0
-      None, cursor[CurMove], CurrentTime) != GrabSuccess)
0
+  None, cursor[CurMove], CurrentTime) != GrabSuccess)
0
     return;
0
-  c->ismax = False;
0
-  XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
0
-  for(;;) {
0
-    XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
0
+  XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
0
+  if(usegrab)
0
+    XGrabServer(dpy);
0
+  do {
0
+    XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
0
     switch (ev.type) {
0
-    case ButtonRelease:
0
-      XUngrabPointer(dpy, CurrentTime);
0
-      return;
0
     case ConfigureRequest:
0
     case Expose:
0
     case MapRequest:
0
       handler[ev.type](&ev);
0
       break;
0
     case MotionNotify:
0
-      XSync(dpy, False);
0
-      nx = ocx + (ev.xmotion.x - x1);
0
-      ny = ocy + (ev.xmotion.y - y1);
0
-      if(abs(wax + nx) < SNAP)
0
-        nx = wax;
0
-      else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
0
-        nx = wax + waw - c->w - 2 * c->border;
0
-      if(abs(way - ny) < SNAP)
0
-        ny = way;
0
-      else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
0
-        ny = way + wah - c->h - 2 * c->border;
0
-      resize(c, nx, ny, c->w, c->h, False);
0
+      nx = ocx + (ev.xmotion.x - x);
0
+      ny = ocy + (ev.xmotion.y - y);
0
+      if(snap && nx >= wx && nx <= wx + ww
0
+              && ny >= wy && ny <= wy + wh) {
0
+        if(abs(wx - nx) < snap)
0
+          nx = wx;
0
+        else if(abs((wx + ww) - (nx + WIDTH(c))) < snap)
0
+          nx = wx + ww - WIDTH(c);
0
+        if(abs(wy - ny) < snap)
0
+          ny = wy;
0
+        else if(abs((wy + wh) - (ny + HEIGHT(c))) < snap)
0
+          ny = wy + wh - HEIGHT(c);
0
+        if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
0
+          togglefloating(NULL);
0
+      }
0
+      if(!lt[sellt]->arrange || c->isfloating)
0
+        resize(c, nx, ny, c->w, c->h, False);
0
       break;
0
     }
0
   }
0
+  while(ev.type != ButtonRelease);
0
+  if(usegrab)
0
+    XUngrabServer(dpy);
0
+  XUngrabPointer(dpy, CurrentTime);
0
 }
0
 
0
 Client *
0
 nexttiled(Client *c) {
0
-  for(; c && (c->isfloating || !isvisible(c)); c = c->next);
0
+  for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
0
   return c;
0
 }
0
 
0
@@ -1134,15 +1002,19 @@ propertynotify(XEvent *e) {
0
     return; /* ignore */
0
   if((c = getclient(ev->window))) {
0
     switch (ev->atom) {
0
-      default: break;
0
-      case XA_WM_TRANSIENT_FOR:
0
-        XGetTransientForHint(dpy, c->win, &trans);
0
-        if(!c->isfloating && (c->isfloating = (NULL != getclient(trans))))
0
-          arrange();
0
-        break;
0
-      case XA_WM_NORMAL_HINTS:
0
-        updatesizehints(c);
0
-        break;
0
+    default: break;
0
+    case XA_WM_TRANSIENT_FOR:
0
+      XGetTransientForHint(dpy, c->win, &trans);
0
+      if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
0
+        arrange();
0
+      break;
0
+    case XA_WM_NORMAL_HINTS:
0
+      updatesizehints(c);
0
+      break;
0
+    case XA_WM_HINTS:
0
+      updatewmhints(c);
0
+      drawbar();
0
+      break;
0
     }
0
     if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
0
       updatetitle(c);
0
@@ -1153,7 +1025,7 @@ propertynotify(XEvent *e) {
0
 }
0
 
0
 void
0
-quit(const char *arg) {
0
+quit(const Arg *arg) {
0
   readin = running = False;
0
 }
0
 
0
@@ -1162,22 +1034,29 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
0
   XWindowChanges wc;
0
 
0
   if(sizehints) {
0
+    /* see last two sentences in ICCCM 4.1.2.3 */
0
+    Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
0
+
0
     /* set minimum possible */
0
-    if (w < 1)
0
-      w = 1;
0
-    if (h < 1)
0
-      h = 1;
0
+    w = MAX(1, w);
0
+    h = MAX(1, h);
0
 
0
-    /* temporarily remove base dimensions */
0
-    w -= c->basew;
0
-    h -= c->baseh;
0
+    if(!baseismin) { /* temporarily remove base dimensions */
0
+      w -= c->basew;
0
+      h -= c->baseh;
0
+    }
0
 
0
     /* adjust for aspect limits */
0
-    if (c->minay > 0 && c->maxay > 0 && c->minax > 0 && c->maxax > 0) {
0
-      if (w * c->maxay > h * c->maxax)
0
-        w = h * c->maxax / c->maxay;
0
-      else if (w * c->minay < h * c->minax)
0
-        h = w * c->minay / c->minax;
0
+    if(c->mina > 0 && c->maxa > 0) {
0
+      if(c->maxa < (float)w / h)
0
+        w = h * c->maxa;
0
+      else if(c->mina < (float)h / w)
0
+        h = w * c->mina;
0
+    }
0
+
0
+    if(baseismin) { /* increment calculation requires this */
0
+      w -= c->basew;
0
+      h -= c->baseh;
0
     }
0
 
0
     /* adjust for increment value */
0
@@ -1190,75 +1069,89 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
0
     w += c->basew;
0
     h += c->baseh;
0
 
0
-    if(c->minw > 0 && w < c->minw)
0
-      w = c->minw;
0
-    if(c->minh > 0 && h < c->minh)
0
-      h = c->minh;
0
-    if(c->maxw > 0 && w > c->maxw)
0
-      w = c->maxw;
0
-    if(c->maxh > 0 && h > c->maxh)
0
-      h = c->maxh;
0
+    w = MAX(w, c->minw);
0
+    h = MAX(h, c->minh);
0
+
0
+    if(c->maxw)
0
+      w = MIN(w, c->maxw);
0
+
0
+    if(c->maxh)
0
+      h = MIN(h, c->maxh);
0
   }
0
   if(w <= 0 || h <= 0)
0
     return;
0
-  /* offscreen appearance fixes */
0
-  if(x > sw)
0
-    x = sw - w - 2 * c->border;
0
-  if(y > sh)
0
-    y = sh - h - 2 * c->border;
0
-  if(x + w + 2 * c->border < sx)
0
+  if(x > sx + sw)
0
+    x = sw - WIDTH(c);
0
+  if(y > sy + sh)
0
+    y = sh - HEIGHT(c);
0
+  if(x + w + 2 * c->bw < sx)
0
     x = sx;
0
-  if(y + h + 2 * c->border < sy)
0
+  if(y + h + 2 * c->bw < sy)
0
     y = sy;
0
+  if(h < bh)
0
+    h = bh;
0
+  if(w < bh)
0
+    w = bh;
0
   if(c->x != x || c->y != y || c->w != w || c->h != h) {
0
     c->x = wc.x = x;
0
     c->y = wc.y = y;
0
     c->w = wc.width = w;
0
     c->h = wc.height = h;
0
-    wc.border_width = c->border;
0
-    XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
0
+    wc.border_width = c->bw;
0
+    XConfigureWindow(dpy, c->win,
0
+        CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
0
     configure(c);
0
     XSync(dpy, False);
0
   }
0
 }
0
 
0
 void
0
-resizemouse(Client *c) {
0
+resizemouse(const Arg *arg) {
0
   int ocx, ocy;
0
   int nw, nh;
0
+  Client *c;
0
   XEvent ev;
0
 
0
+  if(!(c = sel))
0
+    return;
0
+  restack();
0
   ocx = c->x;
0
   ocy = c->y;
0
   if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
0
-      None, cursor[CurResize], CurrentTime) != GrabSuccess)
0
+  None, cursor[CurResize], CurrentTime) != GrabSuccess)
0
     return;
0
-  c->ismax = False;
0
-  XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
0
-  for(;;) {
0
-    XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
0
+  XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
0
+  if(usegrab)
0
+    XGrabServer(dpy);
0
+  do {
0
+    XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
0
     switch(ev.type) {
0
-    case ButtonRelease:
0
-      XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
0
-          c->w + c->border - 1, c->h + c->border - 1);
0
-      XUngrabPointer(dpy, CurrentTime);
0
-      while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
0
-      return;
0
     case ConfigureRequest:
0
     case Expose:
0
     case MapRequest:
0
       handler[ev.type](&ev);
0
       break;
0
     case MotionNotify:
0
-      XSync(dpy, False);
0
-      if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
0
-        nw = 1;
0
-      if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
0
-        nh = 1;
0
-      resize(c, c->x, c->y, nw, nh, True);
0
+      nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1);
0
+      nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1);
0
+
0
+      if(snap && nw >= wx && nw <= wx + ww
0
+              && nh >= wy && nh <= wy + wh) {
0
+        if(!c->isfloating && lt[sellt]->arrange
0
+           && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
0
+          togglefloating(NULL);
0
+      }
0
+      if(!lt[sellt]->arrange || c->isfloating)
0
+        resize(c, c->x, c->y, nw, nh, True);
0
       break;
0
     }
0
   }
0
+  while(ev.type != ButtonRelease);
0
+  if(usegrab)
0
+    XUngrabServer(dpy);
0
+  XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
0
+  XUngrabPointer(dpy, CurrentTime);
0
+  while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
0
 }
0
 
0
 void
0
@@ -1270,21 +1163,16 @@ restack(void) {
0
   drawbar();
0
   if(!sel)
0
     return;
0
-  if(sel->isfloating || isarrange(floating))
0
+  if(sel->isfloating || !lt[sellt]->arrange)
0
     XRaiseWindow(dpy, sel->win);
0
-  if(!isarrange(floating)) {
0
+  if(lt[sellt]->arrange) {
0
     wc.stack_mode = Below;
0
     wc.sibling = barwin;
0
-    if(!sel->isfloating) {
0
-      XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
0
-      wc.sibling = sel->win;
0
-    }
0
-    for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
0
-      if(c == sel)
0
-        continue;
0
-      XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
0
-      wc.sibling = c->win;
0
-    }
0
+    for(c = stack; c; c = c->snext)
0
+      if(!c->isfloating && ISVISIBLE(c)) {
0
+        XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
0
+        wc.sibling = c->win;
0
+      }
0
   }
0
   XSync(dpy, False);
0
   while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
0
@@ -1293,14 +1181,18 @@ restack(void) {
0
 void
0
 run(void) {
0
   char *p;
0
-  int r, xfd;
0
+  char sbuf[sizeof stext];
0
   fd_set rd;
0
+  int r, xfd;
0
+  unsigned int len, offset;
0
   XEvent ev;
0
 
0
   /* main event loop, also reads status text from stdin */
0
   XSync(dpy, False);
0
   xfd = ConnectionNumber(dpy);
0
-  readin = True;
0
+  offset = 0;
0
+  len = sizeof stext - 1;
0
+  sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */
0
   while(running) {
0
     FD_ZERO(&rd);
0
     if(readin)
0
@@ -1309,13 +1201,12 @@ run(void) {
0
     if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
0
       if(errno == EINTR)
0
         continue;
0
-      eprint("select failed\n");
0
+      die("select failed\n");
0
     }
0
     if(FD_ISSET(STDIN_FILENO, &rd)) {
0
-      switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
0
+      switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) {
0
       case -1:
0
-        strncpy(stext, strerror(errno), sizeof stext - 1);
0
-        stext[sizeof stext - 1] = '\0';
0
+        strncpy(stext, strerror(errno), len);
0
         readin = False;
0
         break;
0
       case 0:
0
@@ -1323,10 +1214,18 @@ run(void) {
0
         readin = False;
0
         break;
0
       default:
0
-        for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
0
-        for(; p >= stext && *p != '\n'; --p);
0
-        if(p > stext)
0
-          strncpy(stext, p + 1, sizeof stext);
0
+        for(p = sbuf + offset; r > 0; p++, r--, offset++)
0
+          if(*p == '\n' || *p == '\0') {
0
+            *p = '\0';
0
+            strncpy(stext, sbuf, len);
0
+            p += r - 1; /* p is sbuf + offset + r - 1 */
0
+            for(r = 0; *(p - r) && *(p - r) != '\n'; r++);
0
+            offset = r;
0
+            if(r)
0
+              memmove(sbuf, p - r + 1, r);
0
+            break;
0
+          }
0
+        break;
0
       }
0
       drawbar();
0
     }
0
@@ -1341,10 +1240,9 @@ run(void) {
0
 void
0
 scan(void) {
0
   unsigned int i, num;
0
-  Window *wins, d1