Adding deck layout

This commit is contained in:
bakkeby 2019-09-09 18:00:02 +02:00
parent e490af0eb2
commit 7da1b17169
7 changed files with 178 additions and 2 deletions

View File

@ -112,3 +112,6 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [bstackhoriz](https://dwm.suckless.org/patches/bottomstack/) - [bstackhoriz](https://dwm.suckless.org/patches/bottomstack/)
- bottomstack horizontal layout - bottomstack horizontal layout
- [deck](https://dwm.suckless.org/patches/deck/)
- deck layout

View File

@ -108,6 +108,9 @@ static const Layout layouts[] = {
#if BSTACKHORIZ_LAYOUT #if BSTACKHORIZ_LAYOUT
{ "===", bstackhoriz }, { "===", bstackhoriz },
#endif // BSTACKHORIZ_LAYOUT #endif // BSTACKHORIZ_LAYOUT
#if DECK_LAYOUT
{ "[D]", deck },
#endif // DECK_LAYOUT
#if CYCLELAYOUTS_PATCH #if CYCLELAYOUTS_PATCH
{ NULL, NULL }, { NULL, NULL },
#endif // CYCLELAYOUTS_PATCH #endif // CYCLELAYOUTS_PATCH

156
patch/deck.c Normal file
View File

@ -0,0 +1,156 @@
#if VANITYGAPS_PATCH && CFACTS_PATCH
static void
deck(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, &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;
}
if (n - m->nmaster > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster);
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0);
my += HEIGHT(c) + ih;
} else {
resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
}
}
#elif VANITYGAPS_PATCH
static void
deck(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;
}
if (n - m->nmaster > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster);
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0);
my += HEIGHT(c) + ih;
} else {
resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
}
}
#elif CFACTS_PATCH
static void
deck(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 = 1, sfacts = 1;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
if (n < m->nmaster)
mfacts += c->cfact;
else
sfacts += c->cfact;
}
if (n == 0)
return;
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;
}
if (n - m->nmaster > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster);
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw - (2*c->bw), mh * (c->cfact / mfacts) - (2*c->bw), 0);
my += HEIGHT(c);
} else {
resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
}
}
#else
static void
deck(Monitor *m)
{
unsigned int i, n;
int mx = 0, my = 0, mh = 0, mw = 0;
int sx = 0, sy = 0, sh = 0, sw = 0;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
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;
}
if (n - m->nmaster > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster);
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
resize(c, mx, my, mw - (2*c->bw), mh / MIN(n, m->nmaster) - (2*c->bw), 0);
my += HEIGHT(c);
} else {
resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
}
}
#endif

1
patch/deck.h Normal file
View File

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

View File

@ -62,6 +62,10 @@
#include "bstackhoriz.c" #include "bstackhoriz.c"
#endif #endif
#if DECK_LAYOUT
#include "deck.c"
#endif
#if MONOCLE_LAYOUT #if MONOCLE_LAYOUT
#include "monocle.c" #include "monocle.c"
#endif #endif

View File

@ -58,6 +58,10 @@
#include "bstackhoriz.h" #include "bstackhoriz.h"
#endif #endif
#if DECK_LAYOUT
#include "deck.h"
#endif
#if MONOCLE_LAYOUT #if MONOCLE_LAYOUT
#include "monocle.h" #include "monocle.h"
#endif #endif

View File

@ -197,12 +197,17 @@
*/ */
#define BSTACKHORIZ_LAYOUT 0 #define BSTACKHORIZ_LAYOUT 0
/* Deck layout.
* https://dwm.suckless.org/patches/deck/
*/
#define DECK_LAYOUT 1
/* The default tile layout. /* The default tile layout.
* This can be optionally disabled in favour of other layouts. * This can be optionally disabled in favour of other layouts.
*/ */
#define TILE_LAYOUT 1 #define TILE_LAYOUT 1
/* Monocle (default) /* Monocle layout (default).
* This can be optionally disabled in favour of other layouts. * This can be optionally disabled in favour of other layouts.
*/ */
#define MONOCLE_LAYOUT 1 #define MONOCLE_LAYOUT 1