Greetings to all
This is my first attempt to improve-modify existing open source, so please
forgive any
imperfections or errors. I believe the patch i send applied to 5.0.1 to be
free of any bugs.
It is a simple adaptation of the pertag patch which was at the site to the
new version of dwm.
A friend asked me to write it so i worked with the existing patch.
Hopefully the project maintainer can update the web site with this fixed
version.
Thanks in advance.
diff -up dwm-5.0.1/dwm.c dwm-5.0.1.pertag/dwm.c
--- dwm.c 2008-06-19 11:11:38.000000000 +0300
+++ dwm.c 2008-07-08 23:17:30.000000000 +0300
@@ -237,6 +237,8 @@ static Display *dpy;
static DC dc = {0};
static Layout *lt = NULL;
static Window root, barwin;
+static Layout **ptlt;
+static double *mfacts;
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -272,7 +274,10 @@ applyrules(Client *c) {
void
arrange(void) {
Client *c;
+ int i;
+ for(i = 0; i < LENGTH(tags) && !(tagset[seltags] & 1 << i); i++);
+ lt = ptlt[i]; /* The first visible tag defines the layout */
for(c = clients; c; c = c->next)
if(c->tags & tagset[seltags]) { /* is visible */
if(ismax && !c->isfixed) {
@@ -1300,6 +1305,7 @@ setclientstate(Client *c, long state) {
void
setmfact(const Arg *arg) {
float f;
+ int i;
if(!arg || !lt->arrange)
return;
@@ -1307,6 +1313,9 @@ setmfact(const Arg *arg) {
if(f < 0.1 || f > 0.9)
return;
mfact = f;
+ for(i = 0; i < LENGTH(tags); i++)
+ if(tagset[seltags] & 1 << i)
+ mfacts[i] = mfact; /* Adjust all visible tags mfact */
arrange();
}
@@ -1328,6 +1337,16 @@ setup(void) {
lt = layouts;
updategeom();
+ /* init mfacts array and ptlt array */
+ if(!(mfacts = calloc(LENGTH(tags), sizeof(double))))
+ eprint("Fatal: could not calloc() %d bytes\n", LENGTH(tags) * sizeof(double) );
+ for(i = 0; i < LENGTH(tags); i++)
+ mfacts[i] = mfact;
+ if(!(ptlt = calloc(LENGTH(tags), sizeof(Layout*))))
+ eprint("Fatal: could not calloc() %d bytes\n", LENGTH(tags) * sizeof(Layout *) );
+ for(i = 0; i < LENGTH(tags); i++)
+ ptlt[i] = lt;
+
/* init atoms */
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
@@ -1436,7 +1455,8 @@ tile(void) {
/* master */
c = nexttiled(clients);
- mw = mfact * ww;
+ for(i = 0; i<LENGTH(tags) && !(tagset[seltags] & 1 << i); i++); /* Select mfact from first visible tag */
+ mw = mfacts[i] * ww;
resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
if(--n == 0)
@@ -1480,8 +1500,13 @@ void
togglelayout(const Arg *arg) {
if(arg && arg->v)
lt = (Layout *)arg->v;
- else if(++lt == &layouts[LENGTH(layouts)])
- lt = &layouts[0];
+ else {
+ int i;
+ for(i = 0; i<LENGTH(tags); i++)
+ if( tagset[seltags] & 1 << i )
+ if( ++ptlt[i] == &layouts[LENGTH(layouts)] )
+ ptlt[i] = layouts;
+ }
if(sel)
arrange();
else