I have decided to port the nmaster patch to support the latest
dwm changes about the supertile. I think that the new model is
nice, but it needs more work to be finished.

Here'r my tips.

Out of the tile() layout. there's no way to manage mwfact. This
is wrong, but for floating layout it's fine. In my case (nmaster)
I had to comment out two lines to make it work.

      -  if(!ISTILE)
      -          return;


Also the zoom doesn't works

      -  if(!sel || !ISTILE || sel->isfloating)
                return;
      +  if(!sel || sel->isfloating)
                return;

There's one more reference to ISTILE easy to be killed too.

Some variables has been required to be used by nmaster which are not
exported by dwm.h. Here's the list:

        extern Client *clients;
        extern Client *sel;
        extern double mwfact;
        extern int screen, sx, sy, sw, sh, wax, way, waw, wah;
        extern unsigned int bh, bpos;
        int nmaster = NMASTER;

config.h problem:

There's no way to include "config.h" outside dwm.c, because therer
some variables defined there, not only definitions, so I had to
hardcode these values into the nmaster.c. This is really UGLY..
but I can't find a right way to solve this.

        #define NMASTER 1
        #define BORDERPX 1
        #define RESIZEHINTS False

Another option would be to define those variables into config.mk or
Makefile as -D CFLAGS but in this way we are splitting the configuration
in two files making stupidly complex.

How would you fix that?

Finally I have used to run dwm in this way to log out all the stuff
which is really cool for development.

.xinitrc:

 (sleep 1 && xterm -bg black -fg gray -fn 10x20 -e tail -f ~/.dwm.log) &
 while : ; date ; sleep 1 ; done | dwm > ~/.dwm.log


The nmaster.c patch for dwm-4.6 supertile is attached in config.h
you have to define this:

/* ntile - nmaster */
extern void ntile(void);
void incnmaster(const char *arg);

Layout layouts[] = {
        /* symbol               function */
        { "[]=",                tile }, /* first entry is default */
        { "-|=",                ntile }, /* first entry is default */
        { "><>",                floating },
};
..
        { MODKEY|ShiftMask,             XK_j,           incnmaster,     "+1"}, \
        { MODKEY|ShiftMask,             XK_k,           incnmaster,     "-1"}, \
..



--pancake
/* ntile/nmaster layout for dwm-4.6 */
#if 0
Type this into your config.h

/* ntile - nmaster */
extern void ntile(void);
void incnmaster(const char *arg);

Layout layouts[] = {
        { "-|=",                ntile }, /* first entry is default */
..
        { MODKEY|ShiftMask,             XK_j,           incnmaster,     "+1"}, \
        { MODKEY|ShiftMask,             XK_k,           incnmaster,     "-1"}, \
#endif

#include "dwm.h"

#define NMASTER 1
#define BORDERPX 1
#define RESIZEHINTS False

extern Client *clients;
extern Client *sel;
extern double mwfact;
extern int screen, sx, sy, sw, sh, wax, way, waw, wah;
extern unsigned int bh, bpos;
int nmaster = NMASTER;

void
ntile(void) {
        unsigned int i, n, nx, ny, nw, nh, mw, mh, th;
        Client *c;

        for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
                n++;

        /* window geoms */
        mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
        mw = (n <= nmaster) ? waw : mwfact * waw;
        th = (n > nmaster) ? wah / (n - nmaster) : 0;
        if(n > nmaster && th < bh)
                th = wah;

        nx = wax;
        ny = way;
        for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) {
                c->ismax = False;
                if(i < nmaster) { /* master */
                        ny = way + i * mh;
                        nw = mw - 2 * c->border;
                        nh = mh;
                        if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
                                nh = wah - mh * i;
                        nh -= 2 * c->border;
                }
                else {  /* tile window */
                        if(i == nmaster) {
                                ny = way;
                                nx += mw;
                        }
                        nw = waw - mw - 2 * c->border;
                        if(i + 1 == n) /* remainder */
                                nh = (way + wah) - ny - 2 * c->border;
                        else
                                nh = th - 2 * c->border;
                }
                resize(c, nx, ny, nw, nh, RESIZEHINTS);
                if(n > nmaster && th != wah)
                        ny += nh + 2 * c->border;
        }
}

void
incnmaster(const char *arg) {
        int i;

        if(!isarrange(ntile))
                return;
        if(!arg)
                nmaster = NMASTER;
        else {
                i = atoi(arg);
                if((nmaster + i) < 1 || wah / (nmaster + i) <= 2 * BORDERPX)
                        return;
                nmaster += i;
        }
        if(sel)
                arrange();
}

Reply via email to