mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-27 10:14:14 +00:00
Fix the gridmode patch
This commit is contained in:
parent
68a17f962e
commit
4a3f56c8dd
@ -24,6 +24,7 @@ static const Layout layouts[] = {
|
|||||||
{ "[]=", tile },
|
{ "[]=", tile },
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "HHH", grid },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* monitors */
|
/* monitors */
|
||||||
@ -123,6 +124,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
|
||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
|||||||
36
dwl.c
36
dwl.c
@ -259,6 +259,7 @@ static void focusclient(Client *c, int lift);
|
|||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
static Client *focustop(Monitor *m);
|
static Client *focustop(Monitor *m);
|
||||||
|
static void grid(Monitor *m);
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
static void inputdevice(struct wl_listener *listener, void *data);
|
||||||
@ -1333,6 +1334,41 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
|||||||
setfullscreen(c, client_wants_fullscreen(c));
|
setfullscreen(c, client_wants_fullscreen(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grid(Monitor *m) {
|
||||||
|
unsigned int n = 0, i = 0, ch, cw, rows, cols;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
wl_list_for_each(c, &clients, link)
|
||||||
|
if (VISIBLEON(c, m) && !c->isfloating)
|
||||||
|
n++;
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for (rows = 0; rows <= (n / 2); rows++)
|
||||||
|
if ((rows * rows) >= n)
|
||||||
|
break;
|
||||||
|
cols = (rows && ((rows - 1) * rows) >= n) ? rows - 1 : rows;
|
||||||
|
|
||||||
|
/* window geoms (cell height/width) */
|
||||||
|
ch = m->w.height / (rows ? rows : 1);
|
||||||
|
cw = m->w.width / (cols ? cols : 1);
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
unsigned int cx, cy, ah, aw;
|
||||||
|
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cx = m->w.x + (i / rows) * cw;
|
||||||
|
cy = m->w.y + (i % rows) * ch;
|
||||||
|
/* adjust height/width of last row/column's windows */
|
||||||
|
ah = (((i + 1) % rows) == 0) ? m->w.height - ch * rows : 0;
|
||||||
|
aw = (i >= (rows * (cols - 1))) ? m->w.width - cw * cols : 0;
|
||||||
|
resize(c, (struct wlr_box) { .x = cx, .y = cy, .width = cw - aw, .height = ch - ah }, 0);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user