diff options
| author | Anselm R. Garbe <arg@10kloc.org> | 2006-09-29 12:38:27 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <arg@10kloc.org> | 2006-09-29 12:38:27 +0200 |
| commit | 14d05e7c725a4a07136ceb123cf760272afc1a87 (patch) | |
| tree | 39328e09b357c05afb8951c5aaccaeb844b2b14d | |
| parent | renamed column into area (diff) | |
| download | dwm-14d05e7c725a4a07136ceb123cf760272afc1a87.tar.gz dwm-14d05e7c725a4a07136ceb123cf760272afc1a87.zip | |
first step to a more flexible dotile() algorithm
Diffstat (limited to '')
| -rw-r--r-- | config.arg.h | 6 | ||||
| -rw-r--r-- | config.default.h | 4 | ||||
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | dwm.h | 8 | ||||
| -rw-r--r-- | event.c | 5 | ||||
| -rw-r--r-- | main.c | 4 | ||||
| -rw-r--r-- | view.c | 58 |
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 \ |
| 7 | const char *tags[] = { "dev", "work", "net", "fnord", NULL }; | 7 | const 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 \ |
| @@ -1,5 +1,5 @@ | |||
| 1 | # dwm version | 1 | # dwm version |
| 2 | VERSION = 1.7.1 | 2 | VERSION = 1.8 |
| 3 | 3 | ||
| 4 | # Customize below to fit your system | 4 | # Customize below to fit your system |
| 5 | 5 | ||
| @@ -48,6 +48,10 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | |||
| 48 | enum { ColFG, ColBG, ColLast }; /* color */ | 48 | enum { ColFG, ColBG, ColLast }; /* color */ |
| 49 | 49 | ||
| 50 | typedef enum { | 50 | typedef enum { |
| 51 | StackLeft, StackBottom, StackRight | ||
| 52 | } StackPos; /* stack position*/ | ||
| 53 | |||
| 54 | typedef 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 { | |||
| 97 | extern const char *tags[]; /* all tags */ | 101 | extern const char *tags[]; /* all tags */ |
| 98 | extern char stext[1024]; /* status text */ | 102 | extern char stext[1024]; /* status text */ |
| 99 | extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ | 103 | extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ |
| 100 | extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */ | 104 | extern int master, screen, sx, sy, sw, sh; /* screen geometry, master width */ |
| 101 | extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ | 105 | extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ |
| 102 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | 106 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
| 103 | extern void (*arrange)(Arg *); /* arrange function, indicates mode */ | 107 | extern void (*arrange)(Arg *); /* arrange function, indicates mode */ |
| 104 | extern Atom wmatom[WMLast], netatom[NetLast]; | 108 | extern Atom wmatom[WMLast], netatom[NetLast]; |
| 105 | extern Bool running, issel, *seltag; /* seltag is array of Bool */ | 109 | extern Bool running, issel, *seltag; /* seltag is array of Bool */ |
| 110 | extern Bool isvertical; /* stack direction */ | ||
| 106 | extern Client *clients, *sel, *stack; /* global client list and stack */ | 111 | extern Client *clients, *sel, *stack; /* global client list and stack */ |
| 107 | extern Cursor cursor[CurLast]; | 112 | extern Cursor cursor[CurLast]; |
| 108 | extern DC dc; /* global draw context */ | 113 | extern DC dc; /* global draw context */ |
| 109 | extern Display *dpy; | 114 | extern Display *dpy; |
| 115 | extern StackPos stackpos; | ||
| 110 | extern Window root, barwin; | 116 | extern Window root, barwin; |
| 111 | 117 | ||
| 112 | /* client.c */ | 118 | /* client.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 | } |
| @@ -19,7 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | char stext[1024]; | 20 | char stext[1024]; |
| 21 | Bool *seltag; | 21 | Bool *seltag; |
| 22 | int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh; | 22 | int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh; |
| 23 | unsigned int ntags, numlockmask; | 23 | unsigned int ntags, numlockmask; |
| 24 | Atom wmatom[WMLast], netatom[NetLast]; | 24 | Atom wmatom[WMLast], netatom[NetLast]; |
| 25 | Bool running = True; | 25 | Bool 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; |
| @@ -65,6 +65,8 @@ togglemax(Client *c) | |||
| 65 | /* extern */ | 65 | /* extern */ |
| 66 | 66 | ||
| 67 | void (*arrange)(Arg *) = DEFMODE; | 67 | void (*arrange)(Arg *) = DEFMODE; |
| 68 | Bool isvertical = VERTICALSTACK; | ||
| 69 | StackPos stackpos = STACKPOS; | ||
| 68 | 70 | ||
| 69 | void | 71 | void |
| 70 | detach(Client *c) { | 72 | detach(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 | */ |
| 116 | void | 106 | void |
| 117 | dotile(Arg *arg) { | 107 | dotile(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 | } |
