2
0
mirror of https://github.com/bakkeby/patches synced 2024-11-19 15:25:38 +00:00
patches/dwm/dwm-flextile-6.2.diff

245 lines
7.8 KiB
Diff

From 8dfae1aad85aa7ac03852196d3b77121dfe60aee Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 12:32:08 +0200
Subject: [PATCH] Adding flextile patch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Port of 5.8.2 patch by © 2010 joten <joten@freenet.de>, not compatible with nmaster
or pertag patch as this incorporates a bespoke version of both.
Refer to https://dwm.suckless.org/patches/flextile/
---
config.def.h | 14 +++++++
dwm.c | 112 ++++++++++++++++++++++++++++-----------------------
2 files changed, 75 insertions(+), 51 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..0a8c20f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -21,6 +21,9 @@ static const char *colors[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+/* include(s) depending on the tags array */
+#include "flextile.h"
+
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
@@ -35,6 +38,11 @@ static const Rule rules[] = {
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 */
+static const int layoutaxis[] = {
+ 1, /* layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top */
+ 2, /* master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
+ 2, /* stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
+};
static const Layout layouts[] = {
/* symbol arrange function */
@@ -94,6 +102,12 @@ static Key keys[] = {
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0} }, /* 0 = layout axis */
+ { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1} }, /* 1 = master axis */
+ { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2} }, /* 2 = stack axis */
+ { MODKEY|ControlMask, XK_Return, mirrorlayout, {0} },
+ { MODKEY|ControlMask, XK_h, shiftmastersplit, {.i = -1} }, /* reduce the number of tiled clients in the master area */
+ { MODKEY|ControlMask, XK_l, shiftmastersplit, {.i = +1} }, /* increase the number of tiled clients in the master area */
};
/* button definitions */
diff --git a/dwm.c b/dwm.c
index 4465af1..5a31822 100644
--- a/dwm.c
+++ b/dwm.c
@@ -111,27 +111,6 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
-struct Monitor {
- char ltsymbol[16];
- float mfact;
- int nmaster;
- int num;
- int by; /* bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
- unsigned int sellt;
- unsigned int tagset[2];
- int showbar;
- int topbar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
- const Layout *lt[2];
-};
-
typedef struct {
const char *class;
const char *instance;
@@ -630,6 +609,7 @@ configurerequest(XEvent *e)
Monitor *
createmon(void)
{
+ unsigned int i;
Monitor *m;
m = ecalloc(1, sizeof(Monitor));
@@ -641,6 +621,21 @@ createmon(void)
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ m->ltaxis[0] = layoutaxis[0];
+ m->ltaxis[1] = layoutaxis[1];
+ m->ltaxis[2] = layoutaxis[2];
+ m->msplit = 1;
+ /* init tags, bars, layouts, axes, msplits and mfacts */
+ m->curtag = m->prevtag = 1;
+ for (i = 0; i < LENGTH(tags) + 1; i++) {
+ m->showbars[i] = m->showbar;
+ m->lts[i] = &layouts[0];
+ m->mfacts[i] = m->mfact;
+ m->ltaxes[i][0] = m->ltaxis[0];
+ m->ltaxes[i][1] = m->ltaxis[1];
+ m->ltaxes[i][2] = m->ltaxis[2];
+ m->msplits[i] = m->msplit;
+ }
return m;
}
@@ -1503,7 +1498,7 @@ setlayout(const Arg *arg)
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if (arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1522,7 +1517,7 @@ setmfact(const Arg *arg)
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfact = selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
@@ -1670,36 +1665,10 @@ tagmon(const Arg *arg)
sendmon(selmon->sel, dirtomon(arg->i));
}
-void
-tile(Monitor *m)
-{
- unsigned int i, n, h, mw, my, ty;
- Client *c;
-
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
- if (n == 0)
- return;
-
- if (n > m->nmaster)
- mw = m->nmaster ? m->ww * 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);
- 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);
- ty += HEIGHT(c);
- }
-}
-
void
togglebar(const Arg *arg)
{
- selmon->showbar = !selmon->showbar;
+ selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1723,12 +1692,31 @@ void
toggletag(const Arg *arg)
{
unsigned int newtags;
+ unsigned int i;
if (!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if (newtags) {
selmon->sel->tags = newtags;
+ if (newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if (!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for (i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if (selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
+ selmon->ltaxis[0] = selmon->ltaxes[selmon->curtag][0];
+ selmon->ltaxis[1] = selmon->ltaxes[selmon->curtag][1];
+ selmon->ltaxis[2] = selmon->ltaxes[selmon->curtag][2];
+ selmon->msplit = selmon->msplits[selmon->curtag];
focus(NULL);
arrange(selmon);
}
@@ -2035,11 +2023,33 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{
+ unsigned int i;
+
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if (arg->ui & TAGMASK)
+ if (arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if (arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag = selmon->curtag ^ selmon->prevtag;
+ selmon->curtag ^= selmon->prevtag;
+ selmon->prevtag = selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if (selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
+ selmon->ltaxis[0] = selmon->ltaxes[selmon->curtag][0];
+ selmon->ltaxis[1] = selmon->ltaxes[selmon->curtag][1];
+ selmon->ltaxis[2] = selmon->ltaxes[selmon->curtag][2];
+ selmon->msplit = selmon->msplits[selmon->curtag];
focus(NULL);
arrange(selmon);
}
--
2.17.1