Center floating windows when tiling

This commit is contained in:
Nise Void 2020-05-14 19:39:34 +02:00
parent 60e51c148d
commit 556c9b2fbc
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3
2 changed files with 13 additions and 1 deletions

View File

@ -42,7 +42,7 @@ static const int resizehints = 0; /* 1 means respect size hints in tiled resi
static const Layout layouts[] = {
/* symbol arrange function */
{ "t", tile }, /* first entry is default */
{ "t", centerfloattile }, /* first entry is default */
{ "f", NULL }, /* no layout function means floating behavior */
{ "m", monocle },
};

View File

@ -1,3 +1,15 @@
void centerfloattile(Monitor *m) {
if (!m->sel) return;
if (m->sel->isfloating && !m->sel->isfullscreen && !m->sel->isfixed && m->sel->x == 0 && m->sel->y == 0) {
int x = (m->mw - m->sel->w) / 2;
int y = (m->mh - m->sel->h) / 2;
resize(m->sel, x, y, m->sel->w, m->sel->h, 0);
}
tile(m);
}
void togglefullscreen() {
if (selmon->sel == 0) {
return;