Add toggle for first window centering.
This commit is contained in:
parent
1a9dc79b92
commit
7c60b0a79c
12
config.h
12
config.h
@ -54,6 +54,9 @@ static const Rule rules[] = {
|
||||
{ "Steam", NULL, NULL, 1 << 3, 0, 0, -1 },
|
||||
{ "Lutris", NULL, NULL, 1 << 3, 0, 0, -1 },
|
||||
{ "UE4Editor", NULL, NULL, 1 << 3, 0, 0, -1 },
|
||||
/* zoom */
|
||||
{ "zoom", NULL, NULL, 0, 0, 1, -1 },
|
||||
{ "zoom", NULL, "Zoom Meeting", 0, 0, 1, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
@ -97,7 +100,7 @@ void focusmaster(const Arg* arg);
|
||||
/* variables */
|
||||
static int gamingmodmask = ALTKEY|MODKEY; /* mod keys to disable when gaming */
|
||||
|
||||
static Key togglegamingkey = { MODKEY|ControlMask, XK_g, togglegaming, {0} };
|
||||
static Key togglegamingkey = { MODKEY, XK_g, togglegaming, {0} };
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
@ -119,10 +122,11 @@ static Key keys[] = {
|
||||
{ MODKEY|ControlMask, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_w, killclient, {0} },
|
||||
{ MODKEY, XK_1, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_2, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_3, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_1, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_2, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_3, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_f, togglelayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_p, togglecenterfirst, {0} },
|
||||
{ MODKEY, XK_apostrophe, focusmaster,{0} },
|
||||
{ MODKEY|ControlMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
|
27
dwm.c
27
dwm.c
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user