Compare commits

...

7 Commits

Author SHA1 Message Date
Aryadev Chavali
6b73119c22 Add some more cflags to config.mk 2025-11-26 03:55:13 +00:00
Aryadev Chavali
c3eb171738 Made patch for dwm-scratchpad-ensure-tag 2025-11-26 03:55:09 +00:00
Aryadev Chavali
6426d580be scratchpad: Ensure new clients spawned by scratchpad go to underlying tag
Came from following: https://prithu.dev/posts/debugging-dwm/.  An
issue I thought I had to live with is actually trivial to fix!  Full
credit to them.
2025-11-26 03:55:09 +00:00
Aryadev Chavali
43c355c489 Revert fibonacci, gaplessgrid, centered{master,floatingmaster} patches 2025-11-26 03:55:09 +00:00
Aryadev Chavali
6eb2ae7c8b Delete old layouts from explanation in dwm.1 2025-11-26 03:27:22 +00:00
Aryadev Chavali
f26327a181 Make selected client have a white border 2025-11-26 03:25:18 +00:00
Aryadev Chavali
879e7d351d Add focusonactive patch to DWM
When an application tags itself as "active" i.e. has something to do,
this patch will ensure that we're focused on it.  Works on multiple
monitors!
2025-11-26 03:23:30 +00:00
11 changed files with 107 additions and 527 deletions

View File

@@ -55,8 +55,6 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */ { "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */ { "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle }, { "[M]", monocle },
{ "|M|", centeredmaster },
{ ">M>", centeredfloatingmaster },
}; };
/* key definitions */ /* key definitions */
@@ -101,8 +99,6 @@ static const Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} }, { MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },

View File

@@ -27,7 +27,7 @@ static const char col_dgreen[] = "#008000";
static const char *colors[][3] = { static const char *colors[][3] = {
/* Scheme fg bg border */ /* Scheme fg bg border */
[SchemeNorm] = { col_gray3, col_black, col_black }, [SchemeNorm] = { col_gray3, col_black, col_black },
[SchemeSel] = { col_white, col_black, "#000077" }, [SchemeSel] = { col_white, col_black, col_white },
[SchemeStatus] = { col_white, col_black, col_black }, [SchemeStatus] = { col_white, col_black, col_black },
[SchemeTagsSel] = { col_white, col_gray2, col_black }, [SchemeTagsSel] = { col_white, col_gray2, col_black },
[SchemeTagsNorm] = { col_white, col_black, col_black }, [SchemeTagsNorm] = { col_white, col_black, col_black },
@@ -67,19 +67,11 @@ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
#include "./fibonacci.c"
#include "./gaplessgrid.c"
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "{M}", monocle }, /* first entry is default */ { "{M}", monocle }, /* first entry is default */
{ "[T]=", tile }, { "[T]=", tile },
{ "<F>=", NULL }, /* no layout function means floating behavior */ { "<F>=", NULL }, /* no layout function means floating behavior */
{ "|M|", centeredmaster },
{ ">M>", centeredfloatingmaster },
{ "[@]", spiral },
{ "[\\]", dwindle },
{ "###", gaplessgrid },
{ "[D]", deck }, { "[D]", deck },
}; };
@@ -132,12 +124,7 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} }, { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} },
{ MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} },
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[2]} }, { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[2]} },
{ MODKEY|ShiftMask, XK_o, setlayout, {.v = &layouts[4]} }, { MODKEY|ShiftMask, XK_d, setlayout, {.v = &layouts[3]} },
{ MODKEY|ShiftMask, XK_d, setlayout, {.v = &layouts[8]} },
// { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} },
// { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[5]} },
// { MODKEY|ShiftMask, XK_D, setlayout, {.v = &layouts[6]} },
// { MODKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[7]} },
{ MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, setlayout, {0} },
{ MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_space, togglefloating, {0} },
{ MODKEY, XK_n, focusmon, {.i = -1 } }, { MODKEY, XK_n, focusmon, {.i = -1 } },

View File

@@ -28,7 +28,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
# flags # flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS} LDFLAGS = ${LIBS}
# Solaris # Solaris

42
dwm.1
View File

@@ -17,30 +17,10 @@ area on the left contains one window by default, and the stacking area
on the right contains all other windows. The number of master area on the right contains all other windows. The number of master area
windows can be adjusted from zero to an arbitrary number. windows can be adjusted from zero to an arbitrary number.
.IP \[bu] .IP \[bu]
monocle (normal, centred or floating) monocle: all windows are maximised to the screen size.
Normal: all windows are maximised to the screen size.
Centred: the screen is split into three sections with the master
clients getting the second section and the stacking clients get the
remaining 2 sections to be laid out in.
Floating: the master clients are placed floating in the centre of the
screen while the remaining stacking clients are placed side by side
vertically.
.IP \[bu]
fibonacci (dwindle and spiral): windows are tiled in a spiralling or
dwindling pattern.
In the dwindle layout new clients tend towards the bottom left of the
monitor while in the spiral layout clients tend towards the centre
bottom left.
.IP \[bu] .IP \[bu]
deck: the stacking clients are placed floating on top of each other deck: the stacking clients are placed floating on top of each other
such that there are only two partitions of the screen space. such that there are only two partitions of the screen space.
.IP \[bu]
gapless grid: n clients are arranged into a square of ceil(sqrt(n))
length, where the top left is the latest client opened.
.P .P
Dialog windows are always managed floating, regardless of the layout Dialog windows are always managed floating, regardless of the layout
applied. applied.
@@ -171,26 +151,6 @@ Set layout to floating.
.B Mod\-Shift\-m .B Mod\-Shift\-m
Set layout to monocle. Set layout to monocle.
.TP
.B Mod\-Shift\-u
Set layout to centred monocle.
.TP
.B Mod\-Shift\-o
Set layout to centred floating monocle.
.TP
.B Mod\-Shift\-s
Set layout to spiral fibonacci.
.TP
.B Mod\-Shift\-D
Set layout to dwindle fibonacci.
.TP
.B Mod\-Shift\-g
Set layout to gapless grid.
.TP .TP
.B Mod\-Shift\-d .B Mod\-Shift\-d
Set layout to deck layout. Set layout to deck layout.

118
dwm.c
View File

@@ -245,8 +245,6 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg); static void zoom(const Arg *arg);
static void centeredmaster(Monitor *m);
static void centeredfloatingmaster(Monitor *m);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@@ -571,6 +569,7 @@ clientmessage(XEvent *e)
{ {
XClientMessageEvent *cme = &e->xclient; XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window); Client *c = wintoclient(cme->window);
unsigned int i;
if (!c) if (!c)
return; return;
@@ -585,8 +584,14 @@ clientmessage(XEvent *e)
setsticky(c, (cme->data.l[0] == 1 || setsticky(c, (cme->data.l[0] == 1 ||
(cme->data.l[0] == 2 && !c->issticky))); (cme->data.l[0] == 2 && !c->issticky)));
} else if (cme->message_type == netatom[NetActiveWindow]) { } else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent) for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
seturgent(c, 1); if (i < LENGTH(tags)) {
const Arg a = {.ui = 1 << i};
selmon = c->mon;
view(&a);
focus(c);
restack(selmon);
}
} }
} }
@@ -1172,6 +1177,7 @@ manage(Window w, XWindowAttributes *wa)
c->oldbw = wa->border_width; c->oldbw = wa->border_width;
updatetitle(c); updatetitle(c);
selmon->tagset[selmon->seltags] &= ~scratchtag;
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
c->mon = t->mon; c->mon = t->mon;
c->tags = t->tags; c->tags = t->tags;
@@ -1188,7 +1194,6 @@ manage(Window w, XWindowAttributes *wa)
c->y = MAX(c->y, c->mon->wy); c->y = MAX(c->y, c->mon->wy);
c->bw = borderpx; c->bw = borderpx;
selmon->tagset[selmon->seltags] &= ~scratchtag;
if (!strcmp(c->name, scratchpadname)) { if (!strcmp(c->name, scratchpadname)) {
c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag; c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
c->isfloating = True; c->isfloating = True;
@@ -2559,106 +2564,3 @@ inplacerotate(const Arg *arg)
arrange(selmon); arrange(selmon);
focus(c); focus(c);
} }
void
centeredmaster(Monitor *m)
{
unsigned int i, n, h, mw, mx, my, oty, ety, tw;
Client *c;
/* count number of clients in the selected monitor */
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
/* initialize areas */
mw = m->ww;
mx = 0;
my = 0;
tw = mw;
if (n > m->nmaster) {
/* go mfact box in the center if more than nmaster clients */
mw = m->nmaster ? m->ww * m->mfact : 0;
tw = m->ww - mw;
if (n - m->nmaster > 1) {
/* only one client */
mx = (m->ww - mw) / 2;
tw = (m->ww - mw) / 2;
}
}
oty = 0;
ety = 0;
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
/* nmaster clients are stacked vertically, in the center
* of the screen */
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
h - (2*c->bw), 0);
my += HEIGHT(c);
} else {
/* stack clients are stacked vertically */
if ((i - m->nmaster) % 2 ) {
h = (m->wh - ety) / ( (1 + n - i) / 2);
resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
h - (2*c->bw), 0);
ety += HEIGHT(c);
} else {
h = (m->wh - oty) / ((1 + n - i) / 2);
resize(c, m->wx + mx + mw, m->wy + oty,
tw - (2*c->bw), h - (2*c->bw), 0);
oty += HEIGHT(c);
}
}
}
void
centeredfloatingmaster(Monitor *m)
{
unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
Client *c;
/* count number of clients in the selected monitor */
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
/* initialize nmaster area */
if (n > m->nmaster) {
/* go mfact box in the center if more than nmaster clients */
if (m->ww > m->wh) {
mw = m->nmaster ? m->ww * m->mfact : 0;
mh = m->nmaster ? m->wh * 0.9 : 0;
} else {
mh = m->nmaster ? m->wh * m->mfact : 0;
mw = m->nmaster ? m->ww * 0.9 : 0;
}
mx = mxo = (m->ww - mw) / 2;
my = myo = (m->wh - mh) / 2;
} else {
/* go fullscreen if all clients are in the master area */
mh = m->wh;
mw = m->ww;
mx = mxo = 0;
my = myo = 0;
}
for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
/* nmaster clients are stacked horizontally, in the center
* of the screen */
w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
mh - (2*c->bw), 0);
mx += WIDTH(c);
} else {
/* stack clients are stacked horizontally */
w = (m->ww - tx) / (n - i);
resize(c, m->wx + tx, m->wy, w - (2*c->bw),
m->wh - (2*c->bw), 0);
tx += WIDTH(c);
}
}

View File

@@ -1,66 +0,0 @@
void
fibonacci(Monitor *mon, int s) {
unsigned int i, n, nx, ny, nw, nh;
Client *c;
for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
if(n == 0)
return;
nx = mon->wx;
ny = 0;
nw = mon->ww;
nh = mon->wh;
for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
if((i % 2 && nh / 2 > 2 * c->bw)
|| (!(i % 2) && nw / 2 > 2 * c->bw)) {
if(i < n - 1) {
if(i % 2)
nh /= 2;
else
nw /= 2;
if((i % 4) == 2 && !s)
nx += nw;
else if((i % 4) == 3 && !s)
ny += nh;
}
if((i % 4) == 0) {
if(s)
ny += nh;
else
ny -= nh;
}
else if((i % 4) == 1)
nx += nw;
else if((i % 4) == 2)
ny += nh;
else if((i % 4) == 3) {
if(s)
nx += nw;
else
nx -= nw;
}
if(i == 0)
{
if(n != 1)
nw = mon->ww * mon->mfact;
ny = mon->wy;
}
else if(i == 1)
nw = mon->ww - nw;
i++;
}
resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
}
}
void
dwindle(Monitor *mon) {
fibonacci(mon, 1);
}
void
spiral(Monitor *mon) {
fibonacci(mon, 0);
}

View File

@@ -1,36 +0,0 @@
void
gaplessgrid(Monitor *m) {
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
if(n == 0)
return;
/* grid dimensions */
for(cols = 0; cols <= n/2; cols++)
if(cols*cols >= n)
break;
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
rows = n/cols;
const int gap_size = m->pertag->gaps_current[m->pertag->curtag];
/* window geometries */
cw = cols ? m->ww / cols : m->ww;
cn = 0; /* current column number */
rn = 0; /* current row number */
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
if(i/rows + 1 > cols - n%cols)
rows = n/cols + 1;
ch = (rows ? m->wh / rows : m->wh) - gap_size;
cx = (m->wx + cn*cw) + gap_size;
cy = (m->wy + rn*ch) + gap_size;
resize(c, cx + gap_size, cy + gap_size, cw - 2 * c->bw - gap_size, ch - 2 * c->bw - gap_size, False);
rn++;
if(rn >= rows) {
rn = 0;
cn++;
}
}
}

View File

@@ -1,142 +0,0 @@
diff --git a/config.def.h b/config.def.h
index 7054c06..527b214 100644
--- a/config.def.h
+++ b/config.def.h
@@ -39,6 +39,8 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "|M|", centeredmaster },
+ { ">M>", centeredfloatingmaster },
};
/* key definitions */
@@ -74,6 +76,8 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/dwm.c b/dwm.c
index 0362114..1e81412 100644
--- a/dwm.c
+++ b/dwm.c
@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void centeredmaster(Monitor *m);
+static void centeredfloatingmaster(Monitor *m);
/* variables */
static const char broken[] = "broken";
@@ -2139,3 +2141,106 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
+
+void
+centeredmaster(Monitor *m)
+{
+ unsigned int i, n, h, mw, mx, my, oty, ety, tw;
+ Client *c;
+
+ /* count number of clients in the selected monitor */
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+
+ /* initialize areas */
+ mw = m->ww;
+ mx = 0;
+ my = 0;
+ tw = mw;
+
+ if (n > m->nmaster) {
+ /* go mfact box in the center if more than nmaster clients */
+ mw = m->nmaster ? m->ww * m->mfact : 0;
+ tw = m->ww - mw;
+
+ if (n - m->nmaster > 1) {
+ /* only one client */
+ mx = (m->ww - mw) / 2;
+ tw = (m->ww - mw) / 2;
+ }
+ }
+
+ oty = 0;
+ ety = 0;
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ /* nmaster clients are stacked vertically, in the center
+ * of the screen */
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
+ h - (2*c->bw), 0);
+ my += HEIGHT(c);
+ } else {
+ /* stack clients are stacked vertically */
+ if ((i - m->nmaster) % 2 ) {
+ h = (m->wh - ety) / ( (1 + n - i) / 2);
+ resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
+ h - (2*c->bw), 0);
+ ety += HEIGHT(c);
+ } else {
+ h = (m->wh - oty) / ((1 + n - i) / 2);
+ resize(c, m->wx + mx + mw, m->wy + oty,
+ tw - (2*c->bw), h - (2*c->bw), 0);
+ oty += HEIGHT(c);
+ }
+ }
+}
+
+void
+centeredfloatingmaster(Monitor *m)
+{
+ unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
+ Client *c;
+
+ /* count number of clients in the selected monitor */
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+
+ /* initialize nmaster area */
+ if (n > m->nmaster) {
+ /* go mfact box in the center if more than nmaster clients */
+ if (m->ww > m->wh) {
+ mw = m->nmaster ? m->ww * m->mfact : 0;
+ mh = m->nmaster ? m->wh * 0.9 : 0;
+ } else {
+ mh = m->nmaster ? m->wh * m->mfact : 0;
+ mw = m->nmaster ? m->ww * 0.9 : 0;
+ }
+ mx = mxo = (m->ww - mw) / 2;
+ my = myo = (m->wh - mh) / 2;
+ } else {
+ /* go fullscreen if all clients are in the master area */
+ mh = m->wh;
+ mw = m->ww;
+ mx = mxo = 0;
+ my = myo = 0;
+ }
+
+ for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ /* nmaster clients are stacked horizontally, in the center
+ * of the screen */
+ w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
+ mh - (2*c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ /* stack clients are stacked horizontally */
+ w = (m->ww - tx) / (n - i);
+ resize(c, m->wx + tx, m->wy, w - (2*c->bw),
+ m->wh - (2*c->bw), 0);
+ tx += WIDTH(c);
+ }
+}

View File

@@ -1,114 +0,0 @@
From ec9f55b6005cfa3b025b3d700c61af3ce539d057 Mon Sep 17 00:00:00 2001
From: Niki Yoshiuchi <nyoshiuchi@gmail.com>
Date: Sat, 18 Apr 2020 09:55:26 -0700
Subject: [PATCH] Adding the fibonacci layout patch
---
config.def.h | 5 ++++
fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
create mode 100644 fibonacci.c
diff --git a/config.def.h b/config.def.h
index 1c0b587..5708487 100644
--- a/config.def.h
+++ b/config.def.h
@@ -36,11 +36,14 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
+#include "fibonacci.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "[@]", spiral },
+ { "[\\]", dwindle },
};
/* key definitions */
@@ -76,6 +79,8 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
+ { MODKEY|ShiftMask, XK_r, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/fibonacci.c b/fibonacci.c
new file mode 100644
index 0000000..fce0a57
--- /dev/null
+++ b/fibonacci.c
@@ -0,0 +1,66 @@
+void
+fibonacci(Monitor *mon, int s) {
+ unsigned int i, n, nx, ny, nw, nh;
+ Client *c;
+
+ for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
+ if(n == 0)
+ return;
+
+ nx = mon->wx;
+ ny = 0;
+ nw = mon->ww;
+ nh = mon->wh;
+
+ for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
+ if((i % 2 && nh / 2 > 2 * c->bw)
+ || (!(i % 2) && nw / 2 > 2 * c->bw)) {
+ if(i < n - 1) {
+ if(i % 2)
+ nh /= 2;
+ else
+ nw /= 2;
+ if((i % 4) == 2 && !s)
+ nx += nw;
+ else if((i % 4) == 3 && !s)
+ ny += nh;
+ }
+ if((i % 4) == 0) {
+ if(s)
+ ny += nh;
+ else
+ ny -= nh;
+ }
+ else if((i % 4) == 1)
+ nx += nw;
+ else if((i % 4) == 2)
+ ny += nh;
+ else if((i % 4) == 3) {
+ if(s)
+ nx += nw;
+ else
+ nx -= nw;
+ }
+ if(i == 0)
+ {
+ if(n != 1)
+ nw = mon->ww * mon->mfact;
+ ny = mon->wy;
+ }
+ else if(i == 1)
+ nw = mon->ww - nw;
+ i++;
+ }
+ resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
+ }
+}
+
+void
+dwindle(Monitor *mon) {
+ fibonacci(mon, 1);
+}
+
+void
+spiral(Monitor *mon) {
+ fibonacci(mon, 0);
+}
--
2.20.1

View File

@@ -0,0 +1,57 @@
From 286ca3bb1af08b452bf8140abcc23d4ef61baaa2 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 12:33:04 +0200
Subject: [PATCH] Activate a window in response to _NET_ACTIVE_WINDOW
By default, dwm response to client requests to _NET_ACTIVE_WINDOW client
messages by setting the urgency bit on the named window.
This patch activates the window instead.
Both behaviours are legitimate according to
https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304
One should decide which of these one should perform based on the message
senders' untestable claims that it represents the end-user. Setting the
urgency bit is the conservative decision. This patch implements the more
trusting alternative.
It also allows dwm to work with `wmctrl -a` and other external window
management utilities
---
dwm.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..3919d47 100644
--- a/dwm.c
+++ b/dwm.c
@@ -514,6 +514,7 @@ clientmessage(XEvent *e)
{
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
+ unsigned int i;
if (!c)
return;
@@ -523,8 +524,14 @@ clientmessage(XEvent *e)
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
- if (c != selmon->sel && !c->isurgent)
- seturgent(c, 1);
+ for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
+ if (i < LENGTH(tags)) {
+ const Arg a = {.ui = 1 << i};
+ selmon = c->mon;
+ view(&a);
+ focus(c);
+ restack(selmon);
+ }
}
}
--
2.17.1

View File

@@ -0,0 +1,36 @@
From 51f755111bf1df9ae0dea686a31d2930c723c8b4 Mon Sep 17 00:00:00 2001
From: Aryadev Chavali <aryadev@aryadevchavali.com>
Date: Wed, 26 Nov 2025 03:51:45 +0000
Subject: [PATCH] scratchpad: Ensure new clients spawned by scratchpad go to
underlying tag
Came from following: https://prithu.dev/posts/debugging-dwm/. An
issue I thought I had to live with is actually trivial to fix! Full
credit to them.
---
dwm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
index 719adb3..9e8c3b3 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1177,6 +1177,7 @@ manage(Window w, XWindowAttributes *wa)
c->oldbw = wa->border_width;
updatetitle(c);
+ selmon->tagset[selmon->seltags] &= ~scratchtag;
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
c->mon = t->mon;
c->tags = t->tags;
@@ -1193,7 +1194,6 @@ manage(Window w, XWindowAttributes *wa)
c->y = MAX(c->y, c->mon->wy);
c->bw = borderpx;
- selmon->tagset[selmon->seltags] &= ~scratchtag;
if (!strcmp(c->name, scratchpadname)) {
c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag;
c->isfloating = True;
--
2.51.2