Adding columns layout

This commit is contained in:
bakkeby 2019-10-08 22:57:21 +02:00
parent 83242012da
commit b32fe221b6
9 changed files with 170 additions and 4 deletions

View File

@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2019-10-08 - Added columns layout
2019-10-07 - Added sortscreens and dwmc patches, fixed minor cross-compatibility issues for combo, holdbar, leftlayout, hidevacanttags, taggrid and activetagindicatorbar
2019-10-06 - Added statuscolors and statusallmons patches, fixed minor cross-compatibility issues for killunsel, fullscreen, noborder, tagintostack patches
@ -291,8 +293,11 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [centeredfloatingmaster](https://dwm.suckless.org/patches/centeredmaster/)
- centeredfloatingmaster layout
- [columns](https://dwm.suckless.org/patches/columns/)
- same as the default tile layout except clients in the master area are arranged in columns (i.e. left to right)
- [deck](https://dwm.suckless.org/patches/deck/)
- deck layout
- deck layout - clients in the stack area are arranged on top of each other (like monocle)
- [fibonacci](https://dwm.suckless.org/patches/fibonacci/)
- fibonacci (dwindle and spiral) layouts

View File

@ -258,6 +258,7 @@ static const Layout layouts[] = {
{ "[]=", flextile, { -1, -1, SPLIT_VERTICAL, TOP_TO_BOTTOM, TOP_TO_BOTTOM, 0, NULL } }, // default tile layout
{ "><>", NULL, {0} }, /* no layout function means floating behavior */
{ "[M]", flextile, { -1, -1, NO_SPLIT, MONOCLE, 0, 0, NULL } }, // monocle
{ "|||", flextile, { -1, -1, SPLIT_VERTICAL, LEFT_TO_RIGHT, TOP_TO_BOTTOM, 0, NULL } }, // columns (col) layout
{ ">M>", flextile, { -1, -1, FLOATING_MASTER, LEFT_TO_RIGHT, LEFT_TO_RIGHT, 0, NULL } }, // floating master
{ "[D]", flextile, { -1, -1, SPLIT_VERTICAL, TOP_TO_BOTTOM, MONOCLE, 0, NULL } }, // deck
{ "TTT", flextile, { -1, -1, SPLIT_HORIZONTAL, LEFT_TO_RIGHT, LEFT_TO_RIGHT, 0, NULL } }, // bstack
@ -266,7 +267,6 @@ static const Layout layouts[] = {
{ ":::", flextile, { -1, -1, NO_SPLIT, GAPPLESSGRID, 0, 0, NULL } }, // gappless grid
{ "[\\]", flextile, { -1, -1, NO_SPLIT, DWINDLE, 0, 0, NULL } }, // fibonacci dwindle
{ "(@)", flextile, { -1, -1, NO_SPLIT, SPIRAL, 0, 0, NULL } }, // fibonacci spiral
{ "|||", flextile, { -1, -1, SPLIT_VERTICAL, LEFT_TO_RIGHT, TOP_TO_BOTTOM, 0, NULL } }, // columns (col) layout
#if TILE_LAYOUT
{ "[]=", tile, {0} },
#endif
@ -285,6 +285,9 @@ static const Layout layouts[] = {
#if CENTEREDFLOATINGMASTER_LAYOUT
{ ">M>", centeredfloatingmaster, {0} },
#endif
#if COLUMNS_LAYOUT
{ "|||", col, {0} },
#endif
#if DECK_LAYOUT
{ "[D]", deck, {0} },
#endif
@ -332,6 +335,9 @@ static const Layout layouts[] = {
#if CENTEREDFLOATINGMASTER_LAYOUT
{ ">M>", centeredfloatingmaster },
#endif
#if COLUMNS_LAYOUT
{ "|||", col },
#endif
#if DECK_LAYOUT
{ "[D]", deck },
#endif
@ -471,6 +477,9 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
#if COLUMNS_LAYOUT
{ MODKEY, XK_c, setlayout, {.v = &layouts[3]} },
#endif // COLUMNS_LAYOUT
#if FLEXTILE_DELUXE_LAYOUT
{ MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0 } }, /* flextile, 0 = layout axis */
{ MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1 } }, /* flextile, 1 = master axis */

137
patch/columns.c Normal file
View File

@ -0,0 +1,137 @@
#if VANITYGAPS_PATCH && CFACTS_PATCH
static void
col(Monitor *m)
{
unsigned int i, n;
int mx = 0, my = 0, mh = 0, mw = 0;
int sx = 0, sy = 0, sh = 0, sw = 0;
int oh, ov, ih, iv;
float mfacts, sfacts;
Client *c;
getgaps(m, &oh, &ov, &ih, &iv, &n);
getfacts(m, &mfacts, &sfacts);
if (n == 0)
return;
sx = mx = m->wx + ov;
sy = my = m->wy + oh;
sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
sw = mw = m->ww - 2*ov;
if (m->nmaster && n > m->nmaster) {
sw = (mw - iv) * (1 - m->mfact);
mw = (mw - iv) * m->mfact;
sx = mx + mw + iv;
sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
}
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
mx += WIDTH(c) + iv;
} else {
resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
sy += HEIGHT(c) + ih;
}
}
#elif VANITYGAPS_PATCH
static void
col(Monitor *m)
{
unsigned int i, n;
int mx = 0, my = 0, mh = 0, mw = 0;
int sx = 0, sy = 0, sh = 0, sw = 0;
int oh, ov, ih, iv;
Client *c;
getgaps(m, &oh, &ov, &ih, &iv, &n);
if (n == 0)
return;
sx = mx = m->wx + ov;
sy = my = m->wy + oh;
sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1);
sw = mw = m->ww - 2*ov;
if (m->nmaster && n > m->nmaster) {
sw = (mw - iv) * (1 - m->mfact);
mw = (mw - iv) * m->mfact;
sx = mx + mw + iv;
sh = m->wh - 2*oh - ih * (n - m->nmaster - 1);
}
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
mx += WIDTH(c) + iv;
} else {
resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
sy += HEIGHT(c) + ih;
}
}
#elif CFACTS_PATCH
static void
col(Monitor *m)
{
unsigned int i, n;
int mx = 0, my = 0, mh = 0, mw = 0;
int sx = 0, sy = 0, sh = 0, sw = 0;
float mfacts, sfacts;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
getfacts(m, &mfacts, &sfacts);
sx = mx = m->wx;
sy = my = m->wy;
sh = mh = m->wh;
sw = mw = m->ww;
if (m->nmaster && n > m->nmaster) {
sw = mw * (1 - m->mfact);
mw = mw * m->mfact;
sx = mx + mw;
}
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw * (c->cfact / mfacts) - (2*c->bw), mh - (2*c->bw), 0);
mx += WIDTH(c);
} else {
resize(c, sx, sy, sw - (2*c->bw), sh * (c->cfact / sfacts) - (2*c->bw), 0);
sy += HEIGHT(c);
}
}
#else
void
col(Monitor *m) {
unsigned int i, n, h, w, x, y,mw;
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 = x = y = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
w = (mw - x) / (MIN(n, m->nmaster)-i);
resize(c, x + m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
x += WIDTH(c);
}
else {
h = (m->wh - y) / (n - i);
resize(c, x + m->wx, m->wy + y, m->ww - x - (2*c->bw), h - (2*c->bw), False);
y += HEIGHT(c);
}
}
}
#endif

1
patch/columns.h Normal file
View File

@ -0,0 +1 @@
static void col(Monitor *);

View File

@ -178,6 +178,10 @@
#include "centeredfloatingmaster.c"
#endif
#if COLUMNS_LAYOUT
#include "columns.c"
#endif
#if DECK_LAYOUT
#include "deck.c"
#endif

View File

@ -178,6 +178,10 @@
#include "centeredfloatingmaster.h"
#endif
#if COLUMNS_LAYOUT
#include "columns.h"
#endif
#if DECK_LAYOUT
#include "deck.h"
#endif

View File

@ -106,7 +106,7 @@ incrivgaps(const Arg *arg)
);
}
#if CENTEREDFLOATINGMASTER_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT
#if CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT
static void
getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
{

View File

@ -10,7 +10,7 @@ static void incrivgaps(const Arg *arg);
static void togglegaps(const Arg *arg);
/* Internals */
#if CENTEREDFLOATINGMASTER_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT
#if CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT
static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
#endif // CENTEREDFLOATINGMASTER_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT
static void setgaps(int oh, int ov, int ih, int iv);

View File

@ -490,6 +490,12 @@
*/
#define CENTEREDFLOATINGMASTER_LAYOUT 0
/* Same as the default tile layout except clients in the master area are arranged in
* columns (i.e. left to right).
* https://dwm.suckless.org/patches/columns/
*/
#define COLUMNS_LAYOUT 0
/* Deck layout.
* https://dwm.suckless.org/patches/deck/
*/