aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-13 22:17:03 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-13 22:17:03 +0530
commit9c89f990f79f9a1429d1830661b27d0cb31be21d (patch)
tree80e743401b868e0f2aa51bfa63f86e806c00459a
parentdfc2c40230b73ac47aa535a8bb4560f495428124 (diff)
patched dwm-rmaster-6.2.diff
-rw-r--r--config.def.h4
-rw-r--r--dwm.c23
-rw-r--r--patches/dwm-rmaster-6.2.diff113
3 files changed, 136 insertions, 4 deletions
diff --git a/config.def.h b/config.def.h
index 5285dbd..9293d16 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@ static const char *barlayout = "tln|s";
static const int user_bh = 30;
static const char *fonts[] = { "Noto Sans CJK JP:size=14" };
static const unsigned int gappx = 8;
+static const int rmaster = 1;
static const char *colors[][4] = {
/* fg bg border float */
[SchemeNorm] = { "#bbbbbb", "#282c34", "#282c34", "#282c34" },
@@ -83,6 +84,7 @@ static const Key keys[] = {
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_space, togglermaster, {0} },
//{ MODKEY, XK_h, setmfact, {.f = -0.05} },
//{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
@@ -92,7 +94,7 @@ static const 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_space, setlayout, {0} },
+ //{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
/* functions for "all tags" TODO: map them somewhere, they seem useful */
diff --git a/dwm.c b/dwm.c
index 0c48ff5..437dd70 100644
--- a/dwm.c
+++ b/dwm.c
@@ -125,6 +125,7 @@ struct Monitor {
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
+ int rmaster;
int showbar;
int topbar;
Client *clients;
@@ -220,6 +221,7 @@ static void tagtoright(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglermaster(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -661,6 +663,7 @@ createmon(void)
m->tagset[0] = m->tagset[1] = 1;
m->mfact = mfact;
m->nmaster = nmaster;
+ m->rmaster = rmaster;
m->showbar = showbar;
m->topbar = topbar;
m->gappx = gappx;
@@ -1938,18 +1941,22 @@ tile(Monitor *m)
return;
if (n > m->nmaster)
- mw = m->nmaster ? m->ww * m->mfact : 0;
+ mw = m->nmaster
+ ? m->ww * (m->rmaster ? 1.0 - m->mfact : m->mfact)
+ : 0;
else
mw = m->ww - m->gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
- resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
+ resize(c, m->rmaster ? m->wx + m->ww - mw : m->wx,
+ m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappx < m->wh)
my += HEIGHT(c) + m->gappx;
} else {
h = (m->wh - ty) / (n - i) - m->gappx;
- resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
+ resize(c, m->rmaster ? m->wx : m->wx + mw, m->wy + ty,
+ m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappx < m->wh)
ty += HEIGHT(c) + m->gappx;
}
@@ -1983,6 +1990,16 @@ togglefloating(const Arg *arg)
}
void
+togglermaster(const Arg *arg)
+{
+ selmon->rmaster = !selmon->rmaster;
+ /* now mfact represents the left factor */
+ selmon->mfact = 1.0 - selmon->mfact;
+ if (selmon->lt[selmon->sellt]->arrange)
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
diff --git a/patches/dwm-rmaster-6.2.diff b/patches/dwm-rmaster-6.2.diff
new file mode 100644
index 0000000..3a9088b
--- /dev/null
+++ b/patches/dwm-rmaster-6.2.diff
@@ -0,0 +1,113 @@
+From de2bfe560a8085630ffe976fd5972ee1e8d03916 Mon Sep 17 00:00:00 2001
+From: pskry <peter@skrypalle.dk>
+Date: Mon, 16 Nov 2020 17:47:05 +0100
+Subject: [PATCH] Enable swapping master- and stack-area
+
+Enables swapping the master- and stack area such that the master-client
+appears on the right and the stack-clients appear on the left.
+
+A variable and a toggle-function are introduced to achieve this
+behaviour which are set in the config.h:
+
+* The rmaster-variable can be set to 1 to make the right area the
+default master-area
+* The togglemaster-function can be used to swap the master- and
+stack-areas dynamically.
+---
+ config.def.h | 2 ++
+ dwm.c | 23 ++++++++++++++++++++---
+ 2 files changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..1d00282 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -3,6 +3,7 @@
+ /* appearance */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
++static const int rmaster = 1; /* 1 means master-area is initially on the right */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
+ static const char *fonts[] = { "monospace:size=10" };
+@@ -78,6 +79,7 @@ static Key keys[] = {
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
++ { MODKEY, XK_r, togglermaster, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ { MODKEY, XK_comma, focusmon, {.i = -1 } },
+diff --git a/dwm.c b/dwm.c
+index 4465af1..a2d118b 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -122,6 +122,7 @@ struct Monitor {
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
++ int rmaster;
+ int showbar;
+ int topbar;
+ Client *clients;
+@@ -211,6 +212,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglermaster(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+@@ -636,6 +638,7 @@ createmon(void)
+ m->tagset[0] = m->tagset[1] = 1;
+ m->mfact = mfact;
+ m->nmaster = nmaster;
++ m->rmaster = rmaster;
+ m->showbar = showbar;
+ m->topbar = topbar;
+ m->lt[0] = &layouts[0];
+@@ -1681,17 +1684,21 @@ tile(Monitor *m)
+ return;
+
+ if (n > m->nmaster)
+- mw = m->nmaster ? m->ww * m->mfact : 0;
++ mw = m->nmaster
++ ? m->ww * (m->rmaster ? 1.0 - m->mfact : m->mfact)
++ : 0;
+ else
+ mw = m->ww;
+ for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
++ resize(c, m->rmaster ? m->wx + m->ww - mw : m->wx,
++ m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
+ my += HEIGHT(c);
+ } else {
+ h = (m->wh - ty) / (n - i);
+- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
++ resize(c, m->rmaster ? m->wx : m->wx + mw, m->wy + ty,
++ m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
+ ty += HEIGHT(c);
+ }
+ }
+@@ -1719,6 +1726,16 @@ togglefloating(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++togglermaster(const Arg *arg)
++{
++ selmon->rmaster = !selmon->rmaster;
++ /* now mfact represents the left factor */
++ selmon->mfact = 1.0 - selmon->mfact;
++ if (selmon->lt[selmon->sellt]->arrange)
++ arrange(selmon);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {
+--
+2.31.1
+