[wiki] [sites] 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. || Jeffrey Picard

From: <git_AT_suckless.org>
Date: Thu, 25 Apr 2013 21:17:07 +0200

commit 7b6d303af932f32e676d87ce833e96c3eb0bf16f
Author: Jeffrey Picard <jeff_AT_jeffreypicard.com>
Date: Thu Apr 25 15:14:00 2013 -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.

diff --git a/dwm.suckless.org/patches/dwm-6.1-nlayouts.diff b/dwm.suckless.org/patches/dwm-6.1-nlayouts.diff
new file mode 100644
index 0000000..67f79df
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-6.1-nlayouts.diff
_AT_@ -0,0 +1,50 @@
+diff --git a/dwm.c b/dwm.c
+index 7941bd1..5ce4a35 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -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 */
+_AT_@ -143,7 +145,7 @@ struct Monitor {
+ Client *stack;
+ Monitor *next;
+ Window barwin;
+- const Layout *lt[2];
++ const Layout *lt[NUM_LAYOUTS];
+ };
+
+ typedef struct {
+_AT_@ -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
", sizeof(Monitor));
+_AT_@ -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;
+ }
+_AT_@ -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);
Received on Thu Apr 25 2013 - 21:17:07 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 25 2013 - 21:24:12 CEST