From 77044e876511f51c34bde379d89e2de754707ee6 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 13 Aug 2007 19:13:54 +0200 Subject: made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts --- layout.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'layout.c') diff --git a/layout.c b/layout.c index fe12e1e..a660fd7 100644 --- a/layout.c +++ b/layout.c @@ -2,11 +2,25 @@ #include "dwm.h" #include +typedef struct { + const char *symbol; + void (*arrange)(void); +} Layout; + unsigned int blw = 0; -Layout *lt = NULL; +static Layout *lt = NULL; /* static */ +static void +floating(void) { + Client *c; + + for(c = clients; c; c = c->next) + if(isvisible(c)) + resize(c, c->x, c->y, c->w, c->h, True); +} + static unsigned int nlayouts = 0; LAYOUTS @@ -14,19 +28,15 @@ LAYOUTS /* extern */ void -floating(void) { +arrange(void) { Client *c; - if(lt->arrange != floating) - return; - for(c = clients; c; c = c->next) - if(isvisible(c)) { + if(isvisible(c)) unban(c); - resize(c, c->x, c->y, c->w, c->h, True); - } else ban(c); + lt->arrange(); focus(NULL); restack(); } @@ -55,6 +65,23 @@ focusclient(const char *arg) { } } +const char * +getsymbol(void) +{ + return lt->symbol; +} + +Bool +isfloating(void) { + return lt->arrange == floating; +} + +Bool +isarrange(void (*func)()) +{ + return func == lt->arrange; +} + void initlayouts(void) { unsigned int i, w; @@ -119,7 +146,7 @@ setlayout(const char *arg) { lt = &layout[i]; } if(sel) - lt->arrange(); + arrange(); else drawstatus(); } @@ -131,7 +158,7 @@ togglebar(const char *arg) { else bpos = BarOff; updatebarpos(); - lt->arrange(); + arrange(); } void -- cgit v1.2.3-70-g09d2