Add toggle for first window centering.
This commit is contained in:
@@ -238,6 +238,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
static void centeredmaster(Monitor *m);
|
||||
static void centeredfloatingmaster(Monitor *m);
|
||||
static void togglecenterfirst(const Arg *arg);
|
||||
static void togglelayout(const Arg *arg);
|
||||
static void togglegaming(const Arg *arg);
|
||||
static int iskey(KeySym *keysym, XKeyEvent *ev, Key *key);
|
||||
@@ -276,6 +277,7 @@ static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
static int isgaming = 0;
|
||||
static int centerfirst = 0;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
@@ -1726,12 +1728,14 @@ tile(Monitor *m)
|
||||
return;
|
||||
|
||||
c = nexttiled(m->clients);
|
||||
if (n == 1 && c && c->iscentered){
|
||||
resize(c,
|
||||
if (n == 1 && centerfirst && c && c->iscentered){
|
||||
resize(
|
||||
c,
|
||||
m->wx + m->ww*(1 - m->mfact)/2,
|
||||
m->wy,
|
||||
m->ww * m->mfact - 2 * m->sel->bw,
|
||||
m->wh - 2 * m->sel->bw, 0
|
||||
m->wh - 2 * m->sel->bw,
|
||||
0
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -1752,13 +1756,6 @@ tile(Monitor *m)
|
||||
if (ty + HEIGHT(c) < m->wh)
|
||||
ty += HEIGHT(c);
|
||||
}
|
||||
if (n == 1 && m->sel->iscentered)
|
||||
resize(m->sel,
|
||||
(m->wx + m->ww*(1 - m->mfact)/2),
|
||||
m->wy,
|
||||
m->ww * m->mfact - 2 * m->sel->bw,
|
||||
m->wh - 2 * m->sel->bw, 0
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2337,3 +2334,13 @@ togglegaming(const Arg* arg)
|
||||
grabkeys();
|
||||
}
|
||||
|
||||
void /* toggle center first window */
|
||||
togglecenterfirst(const Arg* arg)
|
||||
{
|
||||
centerfirst ^= 1;
|
||||
if (selmon->sel)
|
||||
arrange(selmon);
|
||||
else
|
||||
drawbar(selmon);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user