Apply resetnmaster patch (no file) and fix existing code

This commit is contained in:
Alex Kotov 2021-11-14 02:26:50 +05:00
parent 5b242a55b2
commit 738de100cb
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 17 additions and 14 deletions

View File

@ -8,6 +8,7 @@ Applied patches
* movestack
* nmaxmaster
* pertag
* resetnmaster
* smartborders
* statusallmons
* systray

View File

@ -73,9 +73,9 @@ static Key keys[] = {
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY|ShiftMask, XK_i, setnmaster, {.i = 1 } },
{ MODKEY|ShiftMask, XK_i, resetnmaster, {.i = nmaster } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY|ShiftMask, XK_d, setnmaster, {.i = 0 } },
{ MODKEY|ShiftMask, XK_d, resetnmaster, {.i = 0 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },

26
dwm.c
View File

@ -215,6 +215,7 @@ static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
static void removesystrayicon(Client *i);
static void resetnmaster(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int bw, int interact);
static void resizebarwin(Monitor *m);
static void resizeclient(Client *c, int x, int y, int w, int h, int bw);
@ -230,7 +231,6 @@ static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setnmaster(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
@ -1626,6 +1626,19 @@ removesystrayicon(Client *i)
free(i);
}
void
resetnmaster(const Arg *arg)
{
const int max_clients_in_master = settings_get_max_clients_in_master();
const int new_clients_in_master = MAX(0, arg->i);
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] =
max_clients_in_master == 0
? new_clients_in_master
: MIN(new_clients_in_master, max_clients_in_master);
arrange(selmon);
}
void
resize(Client *c, int x, int y, int w, int h, int bw, int interact)
@ -1938,17 +1951,6 @@ setmfact(const Arg *arg)
arrange(selmon);
}
void
setnmaster(const Arg *arg)
{
const int new_clients_in_master = arg->i == 0 ? 0 : 1;
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] =
new_clients_in_master;
arrange(selmon);
}
void
setup(void)
{