summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-09-29 12:38:27 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-09-29 12:38:27 +0200
commit14d05e7c725a4a07136ceb123cf760272afc1a87 (patch)
tree39328e09b357c05afb8951c5aaccaeb844b2b14d
parentrenamed column into area (diff)
downloaddwm-14d05e7c725a4a07136ceb123cf760272afc1a87.tar.gz
dwm-14d05e7c725a4a07136ceb123cf760272afc1a87.zip
first step to a more flexible dotile() algorithm
Diffstat (limited to '')
-rw-r--r--config.arg.h6
-rw-r--r--config.default.h4
-rw-r--r--config.mk2
-rw-r--r--dwm.h8
-rw-r--r--event.c5
-rw-r--r--main.c4
-rw-r--r--view.c58
7 files changed, 52 insertions, 35 deletions
diff --git a/config.arg.h b/config.arg.h
index 21c95e5..def5068 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -6,9 +6,11 @@
6#define TAGS \ 6#define TAGS \
7const char *tags[] = { "dev", "work", "net", "fnord", NULL }; 7const char *tags[] = { "dev", "work", "net", "fnord", NULL };
8 8
9#define DEFMODE dotile /* dofloat */ 9#define DEFMODE dotile /* dofloat */
10#define FLOATSYMBOL "><>" 10#define FLOATSYMBOL "><>"
11#define STACKPOS StackRight /* StackLeft, StackBottom */
11#define TILESYMBOL "[]=" 12#define TILESYMBOL "[]="
13#define VERTICALSTACK True /* False == horizontal stack */
12 14
13#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" 15#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
14#define NORMBGCOLOR "#333333" 16#define NORMBGCOLOR "#333333"
@@ -18,7 +20,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
18#define STATUSBGCOLOR "#222222" 20#define STATUSBGCOLOR "#222222"
19#define STATUSFGCOLOR "#9999cc" 21#define STATUSFGCOLOR "#9999cc"
20 22
21#define MASTERW 60 /* percent */ 23#define MASTER 60 /* percent */
22#define MODKEY Mod1Mask 24#define MODKEY Mod1Mask
23 25
24#define KEYS \ 26#define KEYS \
diff --git a/config.default.h b/config.default.h
index 2808ddb..9fd8792 100644
--- a/config.default.h
+++ b/config.default.h
@@ -8,7 +8,9 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
8 8
9#define DEFMODE dotile /* dofloat */ 9#define DEFMODE dotile /* dofloat */
10#define FLOATSYMBOL "><>" 10#define FLOATSYMBOL "><>"
11#define STACKPOS StackRight /* StackLeft, StackBottom */
11#define TILESYMBOL "[]=" 12#define TILESYMBOL "[]="
13#define VERTICALSTACK True /* False == horizontal stack */
12 14
13#define FONT "fixed" 15#define FONT "fixed"
14#define NORMBGCOLOR "#333366" 16#define NORMBGCOLOR "#333366"
@@ -18,7 +20,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
18#define STATUSBGCOLOR "#dddddd" 20#define STATUSBGCOLOR "#dddddd"
19#define STATUSFGCOLOR "#222222" 21#define STATUSFGCOLOR "#222222"
20 22
21#define MASTERW 60 /* percent */ 23#define MASTER 60 /* percent */
22#define MODKEY Mod1Mask 24#define MODKEY Mod1Mask
23 25
24#define KEYS \ 26#define KEYS \
diff --git a/config.mk b/config.mk
index 3872652..e0a1668 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
1# dwm version 1# dwm version
2VERSION = 1.7.1 2VERSION = 1.8
3 3
4# Customize below to fit your system 4# Customize below to fit your system
5 5
diff --git a/dwm.h b/dwm.h
index 234a734..0d2ed3f 100644
--- a/dwm.h
+++ b/dwm.h
@@ -48,6 +48,10 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
48enum { ColFG, ColBG, ColLast }; /* color */ 48enum { ColFG, ColBG, ColLast }; /* color */
49 49
50typedef enum { 50typedef enum {
51 StackLeft, StackBottom, StackRight
52} StackPos; /* stack position*/
53
54typedef enum {
51 TopLeft, TopRight, BotLeft, BotRight 55 TopLeft, TopRight, BotLeft, BotRight
52} Corner; /* window corners */ 56} Corner; /* window corners */
53 57
@@ -97,16 +101,18 @@ struct Client {
97extern const char *tags[]; /* all tags */ 101extern const char *tags[]; /* all tags */
98extern char stext[1024]; /* status text */ 102extern char stext[1024]; /* status text */
99extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ 103extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
100extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */ 104extern int master, screen, sx, sy, sw, sh; /* screen geometry, master width */
101extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ 105extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
102extern void (*handler[LASTEvent])(XEvent *); /* event handler */ 106extern void (*handler[LASTEvent])(XEvent *); /* event handler */
103extern void (*arrange)(Arg *); /* arrange function, indicates mode */ 107extern void (*arrange)(Arg *); /* arrange function, indicates mode */
104extern Atom wmatom[WMLast], netatom[NetLast]; 108extern Atom wmatom[WMLast], netatom[NetLast];
105extern Bool running, issel, *seltag; /* seltag is array of Bool */ 109extern Bool running, issel, *seltag; /* seltag is array of Bool */
110extern Bool isvertical; /* stack direction */
106extern Client *clients, *sel, *stack; /* global client list and stack */ 111extern Client *clients, *sel, *stack; /* global client list and stack */
107extern Cursor cursor[CurLast]; 112extern Cursor cursor[CurLast];
108extern DC dc; /* global draw context */ 113extern DC dc; /* global draw context */
109extern Display *dpy; 114extern Display *dpy;
115extern StackPos stackpos;
110extern Window root, barwin; 116extern Window root, barwin;
111 117
112/* client.c */ 118/* client.c */
diff --git a/event.c b/event.c
index 2df3821..83e1b86 100644
--- a/event.c
+++ b/event.c
@@ -176,8 +176,11 @@ configurerequest(XEvent *e) {
176 else 176 else
177 configure(c); 177 configure(c);
178 XSync(dpy, False); 178 XSync(dpy, False);
179 if(c->isfloat) 179 if(c->isfloat) {
180 resize(c, False, TopLeft); 180 resize(c, False, TopLeft);
181 if(!isvisible(c))
182 ban(c);
183 }
181 else 184 else
182 arrange(NULL); 185 arrange(NULL);
183 } 186 }
diff --git a/main.c b/main.c
index 7cd3a32..a1fdde1 100644
--- a/main.c
+++ b/main.c
@@ -19,7 +19,7 @@
19 19
20char stext[1024]; 20char stext[1024];
21Bool *seltag; 21Bool *seltag;
22int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh; 22int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh;
23unsigned int ntags, numlockmask; 23unsigned int ntags, numlockmask;
24Atom wmatom[WMLast], netatom[NetLast]; 24Atom wmatom[WMLast], netatom[NetLast];
25Bool running = True; 25Bool running = True;
@@ -133,7 +133,7 @@ setup(void) {
133 sx = sy = 0; 133 sx = sy = 0;
134 sw = DisplayWidth(dpy, screen); 134 sw = DisplayWidth(dpy, screen);
135 sh = DisplayHeight(dpy, screen); 135 sh = DisplayHeight(dpy, screen);
136 mw = (sw * MASTERW) / 100; 136 master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
137 137
138 bx = by = 0; 138 bx = by = 0;
139 bw = sw; 139 bw = sw;
diff --git a/view.c b/view.c
index d3378ff..90080fb 100644
--- a/view.c
+++ b/view.c
@@ -65,6 +65,8 @@ togglemax(Client *c)
65/* extern */ 65/* extern */
66 66
67void (*arrange)(Arg *) = DEFMODE; 67void (*arrange)(Arg *) = DEFMODE;
68Bool isvertical = VERTICALSTACK;
69StackPos stackpos = STACKPOS;
68 70
69void 71void
70detach(Client *c) { 72detach(Client *c) {
@@ -97,35 +99,37 @@ dofloat(Arg *arg) {
97 99
98/* This algorithm is based on a (M)aster area and a (S)tacking area. 100/* This algorithm is based on a (M)aster area and a (S)tacking area.
99 * It supports following arrangements: 101 * It supports following arrangements:
100 * 102 * MMMS MMMM SMMM
101 * MMMS MMMM 103 * MMMS MMMM SMMM
102 * MMMS MMMM 104 * MMMS SSSS SMMM
103 * MMMS SSSS
104 *
105 * The stacking area can be set to arrange clients vertically or horizontally.
106 * Through inverting the algorithm it can be used to achieve following setup in
107 * a dual head environment (due to running two dwm instances concurrently on
108 * the specific screen):
109 *
110 * SMM MMS MMM MMM
111 * SMM MMS MMM MMM
112 * SMM MMS SSS SSS
113 *
114 * This uses the center of the two screens for master areas.
115 */ 105 */
116void 106void
117dotile(Arg *arg) { 107dotile(Arg *arg) {
118 int h, i, n, w; 108 int h, i, n, w;
119 Client *c; 109 Client *c;
120 110
121 w = sw - mw;
122 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 111 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
123 n++; 112 n++;
124 113
125 if(n > 1) 114 if(isvertical) {
126 h = (sh - bh) / (n - 1); 115 if(stackpos == StackBottom) {
127 else 116 w = sw;
128 h = sh - bh; 117 if(n > 1)
118 h = (sh - bh) / (n - 1);
119 else
120 h = sh - bh;
121 }
122 else {
123 w = sw - master;
124 if(n > 1)
125 h = (sh - bh) / (n - 1);
126 else
127 h = sh - bh;
128 }
129 }
130 else { /* horizontal stack */
131
132 }
129 133
130 for(i = 0, c = clients; c; c = c->next) { 134 for(i = 0, c = clients; c; c = c->next) {
131 if(isvisible(c)) { 135 if(isvisible(c)) {
@@ -143,11 +147,11 @@ dotile(Arg *arg) {
143 else if(i == 0) { 147 else if(i == 0) {
144 c->x = sx; 148 c->x = sx;
145 c->y = sy + bh; 149 c->y = sy + bh;
146 c->w = mw - 2 * BORDERPX; 150 c->w = master - 2 * BORDERPX;
147 c->h = sh - 2 * BORDERPX - bh; 151 c->h = sh - 2 * BORDERPX - bh;
148 } 152 }
149 else if(h > bh) { 153 else if(h > bh) {
150 c->x = sx + mw; 154 c->x = sx + master;
151 c->y = sy + (i - 1) * h + bh; 155 c->y = sy + (i - 1) * h + bh;
152 c->w = w - 2 * BORDERPX; 156 c->w = w - 2 * BORDERPX;
153 if(i + 1 == n) 157 if(i + 1 == n)
@@ -156,7 +160,7 @@ dotile(Arg *arg) {
156 c->h = h - 2 * BORDERPX; 160 c->h = h - 2 * BORDERPX;
157 } 161 }
158 else { /* fallback if h < bh */ 162 else { /* fallback if h < bh */
159 c->x = sx + mw; 163 c->x = sx + master;
160 c->y = sy + bh; 164 c->y = sy + bh;
161 c->w = w - 2 * BORDERPX; 165 c->w = w - 2 * BORDERPX;
162 c->h = sh - 2 * BORDERPX - bh; 166 c->h = sh - 2 * BORDERPX - bh;
@@ -228,14 +232,14 @@ resizecol(Arg *arg) {
228 return; 232 return;
229 233
230 if(sel == getnext(clients)) { 234 if(sel == getnext(clients)) {
231 if(mw + arg->i > sw - 100 || mw + arg->i < 100) 235 if(master + arg->i > sw - 100 || master + arg->i < 100)
232 return; 236 return;
233 mw += arg->i; 237 master += arg->i;
234 } 238 }
235 else { 239 else {
236 if(mw - arg->i > sw - 100 || mw - arg->i < 100) 240 if(master - arg->i > sw - 100 || master - arg->i < 100)
237 return; 241 return;
238 mw -= arg->i; 242 master -= arg->i;
239 } 243 }
240 arrange(NULL); 244 arrange(NULL);
241} 245}