diff options
Diffstat (limited to '')
| -rw-r--r-- | layout.c | 47 |
1 files changed, 37 insertions, 10 deletions
| @@ -2,11 +2,25 @@ | |||
| 2 | #include "dwm.h" | 2 | #include "dwm.h" |
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | 4 | ||
| 5 | typedef struct { | ||
| 6 | const char *symbol; | ||
| 7 | void (*arrange)(void); | ||
| 8 | } Layout; | ||
| 9 | |||
| 5 | unsigned int blw = 0; | 10 | unsigned int blw = 0; |
| 6 | Layout *lt = NULL; | 11 | static Layout *lt = NULL; |
| 7 | 12 | ||
| 8 | /* static */ | 13 | /* static */ |
| 9 | 14 | ||
| 15 | static void | ||
| 16 | floating(void) { | ||
| 17 | Client *c; | ||
| 18 | |||
| 19 | for(c = clients; c; c = c->next) | ||
| 20 | if(isvisible(c)) | ||
| 21 | resize(c, c->x, c->y, c->w, c->h, True); | ||
| 22 | } | ||
| 23 | |||
| 10 | static unsigned int nlayouts = 0; | 24 | static unsigned int nlayouts = 0; |
| 11 | 25 | ||
| 12 | LAYOUTS | 26 | LAYOUTS |
| @@ -14,19 +28,15 @@ LAYOUTS | |||
| 14 | /* extern */ | 28 | /* extern */ |
| 15 | 29 | ||
| 16 | void | 30 | void |
| 17 | floating(void) { | 31 | arrange(void) { |
| 18 | Client *c; | 32 | Client *c; |
| 19 | 33 | ||
| 20 | if(lt->arrange != floating) | ||
| 21 | return; | ||
| 22 | |||
| 23 | for(c = clients; c; c = c->next) | 34 | for(c = clients; c; c = c->next) |
| 24 | if(isvisible(c)) { | 35 | if(isvisible(c)) |
| 25 | unban(c); | 36 | unban(c); |
| 26 | resize(c, c->x, c->y, c->w, c->h, True); | ||
| 27 | } | ||
| 28 | else | 37 | else |
| 29 | ban(c); | 38 | ban(c); |
| 39 | lt->arrange(); | ||
| 30 | focus(NULL); | 40 | focus(NULL); |
| 31 | restack(); | 41 | restack(); |
| 32 | } | 42 | } |
| @@ -55,6 +65,23 @@ focusclient(const char *arg) { | |||
| 55 | } | 65 | } |
| 56 | } | 66 | } |
| 57 | 67 | ||
| 68 | const char * | ||
| 69 | getsymbol(void) | ||
| 70 | { | ||
| 71 | return lt->symbol; | ||
| 72 | } | ||
| 73 | |||
| 74 | Bool | ||
| 75 | isfloating(void) { | ||
| 76 | return lt->arrange == floating; | ||
| 77 | } | ||
| 78 | |||
| 79 | Bool | ||
| 80 | isarrange(void (*func)()) | ||
| 81 | { | ||
| 82 | return func == lt->arrange; | ||
| 83 | } | ||
| 84 | |||
| 58 | void | 85 | void |
| 59 | initlayouts(void) { | 86 | initlayouts(void) { |
| 60 | unsigned int i, w; | 87 | unsigned int i, w; |
| @@ -119,7 +146,7 @@ setlayout(const char *arg) { | |||
| 119 | lt = &layout[i]; | 146 | lt = &layout[i]; |
| 120 | } | 147 | } |
| 121 | if(sel) | 148 | if(sel) |
| 122 | lt->arrange(); | 149 | arrange(); |
| 123 | else | 150 | else |
| 124 | drawstatus(); | 151 | drawstatus(); |
| 125 | } | 152 | } |
| @@ -131,7 +158,7 @@ togglebar(const char *arg) { | |||
| 131 | else | 158 | else |
| 132 | bpos = BarOff; | 159 | bpos = BarOff; |
| 133 | updatebarpos(); | 160 | updatebarpos(); |
| 134 | lt->arrange(); | 161 | arrange(); |
| 135 | } | 162 | } |
| 136 | 163 | ||
| 137 | void | 164 | void |
