diff options
| author | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-11 12:11:50 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-11 12:11:50 +0200 |
| commit | 2d81b78b853565a3e34a8a9190e2362a6fdde739 (patch) | |
| tree | d58d24853f77685588e42f73a01d782980a3b95e /layout.c | |
| parent | let not overlap the borders (diff) | |
| download | dwm-2d81b78b853565a3e34a8a9190e2362a6fdde739.tar.gz dwm-2d81b78b853565a3e34a8a9190e2362a6fdde739.zip | |
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Diffstat (limited to 'layout.c')
| -rw-r--r-- | layout.c | 116 |
1 files changed, 2 insertions, 114 deletions
| @@ -1,6 +1,5 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | #include "dwm.h" | 2 | #include "dwm.h" |
| 3 | #include <stdio.h> | ||
| 4 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 5 | 4 | ||
| 6 | unsigned int blw = 0; | 5 | unsigned int blw = 0; |
| @@ -15,24 +14,6 @@ LAYOUTS | |||
| 15 | /* extern */ | 14 | /* extern */ |
| 16 | 15 | ||
| 17 | void | 16 | void |
| 18 | floating(const char *arg) { | ||
| 19 | Client *c; | ||
| 20 | |||
| 21 | if(lt->arrange != floating) | ||
| 22 | return; | ||
| 23 | |||
| 24 | for(c = clients; c; c = c->next) | ||
| 25 | if(isvisible(c)) { | ||
| 26 | unban(c); | ||
| 27 | resize(c, c->x, c->y, c->w, c->h, True); | ||
| 28 | } | ||
| 29 | else | ||
| 30 | ban(c); | ||
| 31 | focus(NULL); | ||
| 32 | restack(); | ||
| 33 | } | ||
| 34 | |||
| 35 | void | ||
| 36 | focusclient(const char *arg) { | 17 | focusclient(const char *arg) { |
| 37 | Client *c; | 18 | Client *c; |
| 38 | 19 | ||
| @@ -120,110 +101,17 @@ setlayout(const char *arg) { | |||
| 120 | lt = &layout[i]; | 101 | lt = &layout[i]; |
| 121 | } | 102 | } |
| 122 | if(sel) | 103 | if(sel) |
| 123 | lt->arrange(NULL); | 104 | lt->arrange(); |
| 124 | else | 105 | else |
| 125 | drawstatus(); | 106 | drawstatus(); |
| 126 | } | 107 | } |
| 127 | 108 | ||
| 128 | void | 109 | void |
| 129 | tile(const char *arg) { | ||
| 130 | static double master = MASTER; | ||
| 131 | double delta; | ||
| 132 | unsigned int i, n, nx, ny, nw, nh, mw, th; | ||
| 133 | Client *c; | ||
| 134 | |||
| 135 | if(lt->arrange != tile) | ||
| 136 | return; | ||
| 137 | |||
| 138 | /* arg handling, manipulate master */ | ||
| 139 | if(arg && (1 == sscanf(arg, "%lf", &delta))) { | ||
| 140 | if(delta + master > 0.1 && delta + master < 0.9) | ||
| 141 | master += delta; | ||
| 142 | } | ||
| 143 | |||
| 144 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | ||
| 145 | n++; | ||
| 146 | |||
| 147 | /* window geoms */ | ||
| 148 | mw = (n == 1) ? waw : master * waw; | ||
| 149 | th = (n > 1) ? wah / (n - 1) : 0; | ||
| 150 | if(n > 1 && th < bh) | ||
| 151 | th = wah; | ||
| 152 | |||
| 153 | nx = wax; | ||
| 154 | ny = way; | ||
| 155 | for(i = 0, c = clients; c; c = c->next) | ||
| 156 | if(isvisible(c)) { | ||
| 157 | unban(c); | ||
| 158 | if(c->isfloating) | ||
| 159 | continue; | ||
| 160 | c->ismax = False; | ||
| 161 | if(i == 0) { /* master */ | ||
| 162 | nw = mw - 2 * c->border; | ||
| 163 | nh = wah - 2 * c->border; | ||
| 164 | } | ||
| 165 | else { /* tile window */ | ||
| 166 | if(i == 1) { | ||
| 167 | ny = way; | ||
| 168 | nx += mw; | ||
| 169 | } | ||
| 170 | nw = waw - mw - 2 * c->border; | ||
| 171 | if(i + 1 == n) /* remainder */ | ||
| 172 | nh = (way + wah) - ny - 2 * c->border; | ||
| 173 | else | ||
| 174 | nh = th - 2 * c->border; | ||
| 175 | } | ||
| 176 | resize(c, nx, ny, nw, nh, False); | ||
| 177 | if(n > 1 && th != wah) | ||
| 178 | ny += nh + 2 * c->border; | ||
| 179 | i++; | ||
| 180 | } | ||
| 181 | else | ||
| 182 | ban(c); | ||
| 183 | focus(NULL); | ||
| 184 | restack(); | ||
| 185 | } | ||
| 186 | |||
| 187 | void | ||
| 188 | togglebar(const char *arg) { | 110 | togglebar(const char *arg) { |
| 189 | if(bpos == BarOff) | 111 | if(bpos == BarOff) |
| 190 | bpos = (BARPOS == BarOff) ? BarTop : BARPOS; | 112 | bpos = (BARPOS == BarOff) ? BarTop : BARPOS; |
| 191 | else | 113 | else |
| 192 | bpos = BarOff; | 114 | bpos = BarOff; |
| 193 | updatebarpos(); | 115 | updatebarpos(); |
| 194 | lt->arrange(NULL); | 116 | lt->arrange(); |
| 195 | } | ||
| 196 | |||
| 197 | void | ||
| 198 | togglemax(const char *arg) { | ||
| 199 | XEvent ev; | ||
| 200 | |||
| 201 | if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed) | ||
| 202 | return; | ||
| 203 | if((sel->ismax = !sel->ismax)) { | ||
| 204 | sel->rx = sel->x; | ||
| 205 | sel->ry = sel->y; | ||
| 206 | sel->rw = sel->w; | ||
| 207 | sel->rh = sel->h; | ||
| 208 | resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True); | ||
| 209 | } | ||
| 210 | else | ||
| 211 | resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); | ||
| 212 | drawstatus(); | ||
| 213 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | ||
| 214 | } | ||
| 215 | |||
| 216 | void | ||
| 217 | zoom(const char *arg) { | ||
| 218 | Client *c; | ||
| 219 | |||
| 220 | if(!sel || lt->arrange == floating || sel->isfloating) | ||
| 221 | return; | ||
| 222 | if((c = sel) == nexttiled(clients)) | ||
| 223 | if(!(c = nexttiled(c->next))) | ||
| 224 | return; | ||
| 225 | detach(c); | ||
| 226 | attach(c); | ||
| 227 | focus(c); | ||
| 228 | lt->arrange(NULL); | ||
| 229 | } | 117 | } |
