sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 7b6d303af932f32e676d87ce833e96c3eb0bf16f
parent 80dd55af7f37adaae49660850a241b8dc48e5871
Author: Jeffrey Picard <jeff@jeffreypicard.com>
Date:   Thu, 25 Apr 2013 15:14:00 -0400

This patch allows you to switch between all layouts defined in
config.def.h and not just the first two.
The #define NUM_LAYOUTS at the top of dwm.c is necessary due to
the circular dependencies between variables in config.h and types
in dwm.c so that LENGTH(layouts) can't be used in the Montior struct.

Diffstat:
Adwm.suckless.org/patches/dwm-6.1-nlayouts.diff | 50++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-6.1-nlayouts.diff b/dwm.suckless.org/patches/dwm-6.1-nlayouts.diff @@ -0,0 +1,50 @@ +diff --git a/dwm.c b/dwm.c +index 7941bd1..5ce4a35 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -56,6 +56,8 @@ + #define TAGMASK ((1 << LENGTH(tags)) - 1) + #define TEXTW(X) (textnw(X, strlen(X)) + dc.font.height) + ++#define NUM_LAYOUTS 3 /* Change this to the number of layouts defined in config.def.h */ ++ + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ + enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ +@@ -143,7 +145,7 @@ struct Monitor { + Client *stack; + Monitor *next; + Window barwin; +- const Layout *lt[2]; ++ const Layout *lt[NUM_LAYOUTS]; + }; + + typedef struct { +@@ -649,6 +651,7 @@ configurerequest(XEvent *e) { + Monitor * + createmon(void) { + Monitor *m; ++ unsigned int i; + + if(!(m = (Monitor *)calloc(1, sizeof(Monitor)))) + die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); +@@ -657,8 +660,8 @@ createmon(void) { + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; +- m->lt[0] = &layouts[0]; +- m->lt[1] = &layouts[1 % LENGTH(layouts)]; ++ for( i = 0; i < LENGTH(layouts); i++ ) ++ m->lt[i] = &layouts[i]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + return m; + } +@@ -1563,7 +1566,7 @@ setfullscreen(Client *c, Bool fullscreen) { + void + setlayout(const Arg *arg) { + if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) +- selmon->sellt ^= 1; ++ selmon->sellt = (selmon->sellt + 1) % LENGTH(layouts); + if(arg && arg->v) + selmon->lt[selmon->sellt] = (Layout *)arg->v; + strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);