diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 17:00:32 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 17:00:32 +0100 |
| commit | cee56d38632bbac08e7f59d58c7c7ab1370be329 (patch) | |
| tree | 53869a5d9d948bbd25f51a57f531e9b7d4f282af /screen.c | |
| parent | removed debug compile flags (diff) | |
| download | dwm-cee56d38632bbac08e7f59d58c7c7ab1370be329.tar.gz dwm-cee56d38632bbac08e7f59d58c7c7ab1370be329.zip | |
renamed floating into swimming (this does not clash with C naming conventions and fits better the fish symbol) - also in man page
Diffstat (limited to 'screen.c')
| -rw-r--r-- | screen.c | 133 |
1 files changed, 67 insertions, 66 deletions
| @@ -19,7 +19,7 @@ Layout *lt = NULL; | |||
| 19 | typedef struct { | 19 | typedef struct { |
| 20 | const char *prop; | 20 | const char *prop; |
| 21 | const char *tags; | 21 | const char *tags; |
| 22 | Bool isfloat; | 22 | Bool swimming; |
| 23 | } Rule; | 23 | } Rule; |
| 24 | 24 | ||
| 25 | typedef struct { | 25 | typedef struct { |
| @@ -27,7 +27,6 @@ typedef struct { | |||
| 27 | regex_t *tagregex; | 27 | regex_t *tagregex; |
| 28 | } Regs; | 28 | } Regs; |
| 29 | 29 | ||
| 30 | LAYOUTS | ||
| 31 | TAGS | 30 | TAGS |
| 32 | RULES | 31 | RULES |
| 33 | 32 | ||
| @@ -35,60 +34,8 @@ static Regs *regs = NULL; | |||
| 35 | static unsigned int nrules = 0; | 34 | static unsigned int nrules = 0; |
| 36 | static unsigned int nlayouts = 0; | 35 | static unsigned int nlayouts = 0; |
| 37 | 36 | ||
| 38 | /* extern */ | 37 | static void |
| 39 | 38 | tile(void) { | |
| 40 | void | ||
| 41 | compileregs(void) { | ||
| 42 | unsigned int i; | ||
| 43 | regex_t *reg; | ||
| 44 | |||
| 45 | if(regs) | ||
| 46 | return; | ||
| 47 | nrules = sizeof rule / sizeof rule[0]; | ||
| 48 | regs = emallocz(nrules * sizeof(Regs)); | ||
| 49 | for(i = 0; i < nrules; i++) { | ||
| 50 | if(rule[i].prop) { | ||
| 51 | reg = emallocz(sizeof(regex_t)); | ||
| 52 | if(regcomp(reg, rule[i].prop, REG_EXTENDED)) | ||
| 53 | free(reg); | ||
| 54 | else | ||
| 55 | regs[i].propregex = reg; | ||
| 56 | } | ||
| 57 | if(rule[i].tags) { | ||
| 58 | reg = emallocz(sizeof(regex_t)); | ||
| 59 | if(regcomp(reg, rule[i].tags, REG_EXTENDED)) | ||
| 60 | free(reg); | ||
| 61 | else | ||
| 62 | regs[i].tagregex = reg; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | void | ||
| 68 | dofloat(void) { | ||
| 69 | Client *c; | ||
| 70 | |||
| 71 | for(c = clients; c; c = c->next) { | ||
| 72 | if(isvisible(c)) { | ||
| 73 | if(c->isbanned) | ||
| 74 | XMoveWindow(dpy, c->win, c->x, c->y); | ||
| 75 | c->isbanned = False; | ||
| 76 | resize(c, c->x, c->y, c->w, c->h, True); | ||
| 77 | } | ||
| 78 | else { | ||
| 79 | c->isbanned = True; | ||
| 80 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | if(!sel || !isvisible(sel)) { | ||
| 84 | for(c = stack; c && !isvisible(c); c = c->snext); | ||
| 85 | focus(c); | ||
| 86 | } | ||
| 87 | restack(); | ||
| 88 | } | ||
| 89 | |||
| 90 | void | ||
| 91 | dotile(void) { | ||
| 92 | unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; | 39 | unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
| 93 | Client *c; | 40 | Client *c; |
| 94 | 41 | ||
| @@ -105,7 +52,7 @@ dotile(void) { | |||
| 105 | if(c->isbanned) | 52 | if(c->isbanned) |
| 106 | XMoveWindow(dpy, c->win, c->x, c->y); | 53 | XMoveWindow(dpy, c->win, c->x, c->y); |
| 107 | c->isbanned = False; | 54 | c->isbanned = False; |
| 108 | if(c->isfloat) | 55 | if(c->swimming) |
| 109 | continue; | 56 | continue; |
| 110 | c->ismax = False; | 57 | c->ismax = False; |
| 111 | nx = wax; | 58 | nx = wax; |
| @@ -139,9 +86,40 @@ dotile(void) { | |||
| 139 | restack(); | 86 | restack(); |
| 140 | } | 87 | } |
| 141 | 88 | ||
| 89 | LAYOUTS | ||
| 90 | |||
| 91 | /* extern */ | ||
| 92 | |||
| 93 | void | ||
| 94 | compileregs(void) { | ||
| 95 | unsigned int i; | ||
| 96 | regex_t *reg; | ||
| 97 | |||
| 98 | if(regs) | ||
| 99 | return; | ||
| 100 | nrules = sizeof rule / sizeof rule[0]; | ||
| 101 | regs = emallocz(nrules * sizeof(Regs)); | ||
| 102 | for(i = 0; i < nrules; i++) { | ||
| 103 | if(rule[i].prop) { | ||
| 104 | reg = emallocz(sizeof(regex_t)); | ||
| 105 | if(regcomp(reg, rule[i].prop, REG_EXTENDED)) | ||
| 106 | free(reg); | ||
| 107 | else | ||
| 108 | regs[i].propregex = reg; | ||
| 109 | } | ||
| 110 | if(rule[i].tags) { | ||
| 111 | reg = emallocz(sizeof(regex_t)); | ||
| 112 | if(regcomp(reg, rule[i].tags, REG_EXTENDED)) | ||
| 113 | free(reg); | ||
| 114 | else | ||
| 115 | regs[i].tagregex = reg; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 142 | void | 120 | void |
| 143 | incnmaster(Arg *arg) { | 121 | incnmaster(Arg *arg) { |
| 144 | if((lt->arrange == dofloat) || (nmaster + arg->i < 1) | 122 | if((lt->arrange != tile) || (nmaster + arg->i < 1) |
| 145 | || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) | 123 | || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) |
| 146 | return; | 124 | return; |
| 147 | nmaster += arg->i; | 125 | nmaster += arg->i; |
| @@ -176,7 +154,7 @@ isvisible(Client *c) { | |||
| 176 | 154 | ||
| 177 | void | 155 | void |
| 178 | resizemaster(Arg *arg) { | 156 | resizemaster(Arg *arg) { |
| 179 | if(lt->arrange != dotile) | 157 | if(lt->arrange != tile) |
| 180 | return; | 158 | return; |
| 181 | if(arg->i == 0) | 159 | if(arg->i == 0) |
| 182 | master = MASTER; | 160 | master = MASTER; |
| @@ -197,10 +175,10 @@ restack(void) { | |||
| 197 | drawstatus(); | 175 | drawstatus(); |
| 198 | if(!sel) | 176 | if(!sel) |
| 199 | return; | 177 | return; |
| 200 | if(sel->isfloat || lt->arrange == dofloat) | 178 | if(sel->swimming || lt->arrange == swim) |
| 201 | XRaiseWindow(dpy, sel->win); | 179 | XRaiseWindow(dpy, sel->win); |
| 202 | if(lt->arrange != dofloat) { | 180 | if(lt->arrange != swim) { |
| 203 | if(!sel->isfloat) | 181 | if(!sel->swimming) |
| 204 | XLowerWindow(dpy, sel->win); | 182 | XLowerWindow(dpy, sel->win); |
| 205 | for(c = nexttiled(clients); c; c = nexttiled(c->next)) { | 183 | for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
| 206 | if(c == sel) | 184 | if(c == sel) |
| @@ -230,7 +208,7 @@ settags(Client *c, Client *trans) { | |||
| 230 | ch.res_name ? ch.res_name : "", c->name); | 208 | ch.res_name ? ch.res_name : "", c->name); |
| 231 | for(i = 0; i < nrules; i++) | 209 | for(i = 0; i < nrules; i++) |
| 232 | if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { | 210 | if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
| 233 | c->isfloat = rule[i].isfloat; | 211 | c->swimming = rule[i].swimming; |
| 234 | for(j = 0; regs[i].tagregex && j < ntags; j++) { | 212 | for(j = 0; regs[i].tagregex && j < ntags; j++) { |
| 235 | if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { | 213 | if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { |
| 236 | matched = True; | 214 | matched = True; |
| @@ -249,6 +227,29 @@ settags(Client *c, Client *trans) { | |||
| 249 | } | 227 | } |
| 250 | 228 | ||
| 251 | void | 229 | void |
| 230 | swim(void) { | ||
| 231 | Client *c; | ||
| 232 | |||
| 233 | for(c = clients; c; c = c->next) { | ||
| 234 | if(isvisible(c)) { | ||
| 235 | if(c->isbanned) | ||
| 236 | XMoveWindow(dpy, c->win, c->x, c->y); | ||
| 237 | c->isbanned = False; | ||
| 238 | resize(c, c->x, c->y, c->w, c->h, True); | ||
| 239 | } | ||
| 240 | else { | ||
| 241 | c->isbanned = True; | ||
| 242 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | ||
| 243 | } | ||
| 244 | } | ||
| 245 | if(!sel || !isvisible(sel)) { | ||
| 246 | for(c = stack; c && !isvisible(c); c = c->snext); | ||
| 247 | focus(c); | ||
| 248 | } | ||
| 249 | restack(); | ||
| 250 | } | ||
| 251 | |||
| 252 | void | ||
| 252 | tag(Arg *arg) { | 253 | tag(Arg *arg) { |
| 253 | unsigned int i; | 254 | unsigned int i; |
| 254 | 255 | ||
| @@ -262,10 +263,10 @@ tag(Arg *arg) { | |||
| 262 | } | 263 | } |
| 263 | 264 | ||
| 264 | void | 265 | void |
| 265 | togglefloat(Arg *arg) { | 266 | toggleswimming(Arg *arg) { |
| 266 | if(!sel || lt->arrange == dofloat) | 267 | if(!sel || lt->arrange == swim) |
| 267 | return; | 268 | return; |
| 268 | sel->isfloat = !sel->isfloat; | 269 | sel->swimming = !sel->swimming; |
| 269 | lt->arrange(); | 270 | lt->arrange(); |
| 270 | } | 271 | } |
| 271 | 272 | ||
