mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding deck layout
This commit is contained in:
parent
e490af0eb2
commit
7da1b17169
@ -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/)
|
||||
- bottomstack horizontal layout
|
||||
|
||||
- [deck](https://dwm.suckless.org/patches/deck/)
|
||||
- deck layout
|
@ -108,6 +108,9 @@ static const Layout layouts[] = {
|
||||
#if BSTACKHORIZ_LAYOUT
|
||||
{ "===", bstackhoriz },
|
||||
#endif // BSTACKHORIZ_LAYOUT
|
||||
#if DECK_LAYOUT
|
||||
{ "[D]", deck },
|
||||
#endif // DECK_LAYOUT
|
||||
#if CYCLELAYOUTS_PATCH
|
||||
{ NULL, NULL },
|
||||
#endif // CYCLELAYOUTS_PATCH
|
||||
|
156
patch/deck.c
Normal file
156
patch/deck.c
Normal 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
1
patch/deck.h
Normal file
@ -0,0 +1 @@
|
||||
static void deck(Monitor *m);
|
@ -62,6 +62,10 @@
|
||||
#include "bstackhoriz.c"
|
||||
#endif
|
||||
|
||||
#if DECK_LAYOUT
|
||||
#include "deck.c"
|
||||
#endif
|
||||
|
||||
#if MONOCLE_LAYOUT
|
||||
#include "monocle.c"
|
||||
#endif
|
||||
|
@ -58,6 +58,10 @@
|
||||
#include "bstackhoriz.h"
|
||||
#endif
|
||||
|
||||
#if DECK_LAYOUT
|
||||
#include "deck.h"
|
||||
#endif
|
||||
|
||||
#if MONOCLE_LAYOUT
|
||||
#include "monocle.h"
|
||||
#endif
|
||||
|
@ -197,12 +197,17 @@
|
||||
*/
|
||||
#define BSTACKHORIZ_LAYOUT 0
|
||||
|
||||
/* Deck layout.
|
||||
* https://dwm.suckless.org/patches/deck/
|
||||
*/
|
||||
#define DECK_LAYOUT 1
|
||||
|
||||
/* The default tile layout.
|
||||
* This can be optionally disabled in favour of other layouts.
|
||||
*/
|
||||
#define TILE_LAYOUT 1
|
||||
|
||||
/* Monocle (default)
|
||||
/* Monocle layout (default).
|
||||
* This can be optionally disabled in favour of other layouts.
|
||||
*/
|
||||
#define MONOCLE_LAYOUT 1
|
Loading…
Reference in New Issue
Block a user