forked from RepoMirrors/dwl
implement bottomstack
This commit is contained in:
parent
1ad39f72eb
commit
c4b11e4365
@ -36,6 +36,8 @@ static const Layout layouts[] = {
|
||||
{ "[M]", monocle },
|
||||
{ "###", gaplessgrid },
|
||||
{ "|M|", centeredmaster },
|
||||
{ "TTT", bstack },
|
||||
{ "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@ -143,6 +145,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_c, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XKB_KEY_u, setlayout, {.v = &layouts[5]} },
|
||||
{ MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[6]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
|
84
dwl.c
84
dwl.c
@ -58,6 +58,7 @@
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
@ -358,6 +359,8 @@ static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
static void zoom(const Arg *arg);
|
||||
static void bstack(Monitor *m);
|
||||
static void bstackhoriz(Monitor *m);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@ -3349,3 +3352,84 @@ main(int argc, char *argv[])
|
||||
usage:
|
||||
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
bstack(Monitor *m)
|
||||
{
|
||||
int w, h, mh, mx, tx, ty, tw;
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating)
|
||||
n++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n > m->nmaster) {
|
||||
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
tw = m->w.width / (n - m->nmaster);
|
||||
ty = m->w.y + mh;
|
||||
} else {
|
||||
mh = m->w.height;
|
||||
tw = m->w.width;
|
||||
ty = m->w.y;
|
||||
}
|
||||
|
||||
i = mx = 0;
|
||||
tx = m-> w.x;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || c->isfloating)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
mx += c->geom.width;
|
||||
} else {
|
||||
h = m->w.height - mh;
|
||||
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0);
|
||||
if (tw != m->w.width)
|
||||
tx += c->geom.width;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bstackhoriz(Monitor *m) {
|
||||
int w, mh, mx, tx, ty, th;
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating)
|
||||
n ++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n > m->nmaster) {
|
||||
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
th = (m->w.height - mh) / (n - m->nmaster);
|
||||
ty = m->w.y + mh;
|
||||
} else {
|
||||
th = mh = m->w.height;
|
||||
ty = m->w.y;
|
||||
}
|
||||
|
||||
i = mx = 0;
|
||||
tx = m-> w.x;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c,m) || c->isfloating)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
mx += c->geom.width;
|
||||
} else {
|
||||
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0);
|
||||
if (th != m->w.height)
|
||||
ty += c->geom.height;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user