summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 2af7979..f4965e8 100644
--- a/dwm.c
+++ b/dwm.c
@@ -197,6 +197,7 @@ static void pushdown(const Arg *arg);
static void pushup(const Arg *arg);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
+static void resetlayout(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
@@ -1389,6 +1390,18 @@ recttomon(int x, int y, int w, int h)
}
void
+resetlayout(const Arg *arg)
+{
+ Arg default_layout = {.v = &layouts[0]};
+ Arg default_mfact = {.f = mfact + 1};
+ Arg default_nmaster = {.i = nmaster - selmon->nmaster};
+
+ setlayout(&default_layout);
+ setmfact(&default_mfact);
+ incnmaster(&default_nmaster);
+}
+
+void
resize(Client *c, int x, int y, int w, int h, int interact)
{
if (applysizehints(c, &x, &y, &w, &h, interact))
@@ -1405,6 +1418,10 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+
+ if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next)))
+ resetlayout(NULL);
+
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);