Move more stuff to layouts.c
This commit is contained in:
parent
06f46b1603
commit
01580f2bb3
|
@ -77,9 +77,6 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
static const int decorhints = 1; /* 1 means respect decoration hints */
|
static const int decorhints = 1; /* 1 means respect decoration hints */
|
||||||
|
|
||||||
#include "layouts.c"
|
|
||||||
#include "horizgrid.c"
|
|
||||||
#include "gaplessgrid.c"
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
@ -164,13 +161,13 @@ static Key keys[] = {
|
||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static Button buttons[] = {
|
static Button buttons[] = {
|
||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkButton, 0, Button1, spawn, {.v = dmenucmd } },
|
{ ClkButton, 0, Button1, spawn, SHCMD("j4-dmenu-desktop --dmenu dmenu -fn 'Hack Nerd Font:size=14' -nb '#173f4f' -nf '#ffffff' -sb '#124f5f' -sf '#eeeeee' -g 6 -l 6 --term st") },
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
{ ClkFollowSymbol, 0, Button1, togglefollow, {0} },
|
{ ClkFollowSymbol, 0, Button1, togglefollow, {0} },
|
||||||
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, SHCMD("st -e") },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
|
|
@ -322,6 +322,8 @@ static Visual *visual;
|
||||||
static int depth;
|
static int depth;
|
||||||
static Colormap cmap;
|
static Colormap cmap;
|
||||||
|
|
||||||
|
#include "layouts.c"
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -2035,8 +2037,6 @@ sigchld(int unused)
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
|
||||||
dmenumon[0] = '0' + selmon->num;
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
|
|
|
@ -25,3 +25,72 @@ grid(Monitor *m) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gaplessgrid(Monitor *m) {
|
||||||
|
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for(cols = 0; cols <= n/2; cols++)
|
||||||
|
if(cols*cols >= n)
|
||||||
|
break;
|
||||||
|
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||||
|
cols = 2;
|
||||||
|
rows = n/cols;
|
||||||
|
|
||||||
|
/* window geometries */
|
||||||
|
cw = cols ? m->ww / cols : m->ww;
|
||||||
|
cn = 0; /* current column number */
|
||||||
|
rn = 0; /* current row number */
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||||
|
if(i/rows + 1 > cols - n%cols)
|
||||||
|
rows = n/cols + 1;
|
||||||
|
ch = rows ? m->wh / rows : m->wh;
|
||||||
|
cx = m->wx + cn*cw;
|
||||||
|
cy = m->wy + rn*ch;
|
||||||
|
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||||
|
rn++;
|
||||||
|
if(rn >= rows) {
|
||||||
|
rn = 0;
|
||||||
|
cn++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
horizgrid(Monitor *m) {
|
||||||
|
Client *c;
|
||||||
|
unsigned int n, i;
|
||||||
|
int w = 0;
|
||||||
|
int ntop, nbottom = 0;
|
||||||
|
|
||||||
|
/* Count windows */
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
else if(n == 1) { /* Just fill the whole screen */
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else if(n == 2) { /* Split vertically */
|
||||||
|
w = m->ww / 2;
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
c = nexttiled(c->next);
|
||||||
|
resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else {
|
||||||
|
ntop = n / 2;
|
||||||
|
nbottom = n - ntop;
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if(i < ntop)
|
||||||
|
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
else
|
||||||
|
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue