From 6085246aa8c9446956cef7608f127b4f8af9322b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 11 Sep 2007 15:53:03 +0200 Subject: [PATCH] change incnmaster to setnmaster --- config.c | 2 +- layouts/tile.c | 19 +++++++++++-------- layouts/tile.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config.c b/config.c index 77569fc6f..ed6ca53ec 100644 --- a/config.c +++ b/config.c @@ -93,7 +93,7 @@ static const NameFuncLink KeyfuncList[] = { {"zoom", uicb_zoom}, /* layouts/tile.c */ {"setmwfact", uicb_setmwfact}, - {"incnmaster", uicb_incnmaster}, + {"setnmaster", uicb_setnmaster}, /* awesome.c */ {"quit", uicb_quit}, {NULL, NULL} diff --git a/layouts/tile.c b/layouts/tile.c index f06f7f3a3..662e86299 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -12,28 +12,31 @@ extern Client *sel, *clients; /* static */ -static double mwfact = 0.6; static void _tile(awesome_config *, const Bool); /* arranges all windows tiled */ +static double mwfact = 0.6; static int nmaster = 2; void -uicb_incnmaster(Display *disp, +uicb_setnmaster(Display *disp, awesome_config *awesomeconf, const char * arg) { - int i; + int delta; if(!IS_ARRANGE(tile) && !IS_ARRANGE(tileleft) && !IS_ARRANGE(bstack) && !IS_ARRANGE(bstackportrait)) return; if(!arg) nmaster = awesomeconf->nmaster; - else + else if(sscanf(arg, "%d", &delta)) { - i = strtol(arg, (char **) NULL, 10); - if((nmaster + i) < 1 || wah / (nmaster + i) <= 2 * awesomeconf->borderpx) + if((arg[0] == '+' || arg[0] == '-') + && !((nmaster + delta) < 1 || wah / (nmaster + delta) <= 2 * awesomeconf->borderpx)) + nmaster += delta; + else if(delta >= 1 && wah / delta <= 2 * awesomeconf->borderpx) + nmaster = delta; + else return; - nmaster += i; } if(sel) arrange(disp, awesomeconf); @@ -54,7 +57,7 @@ uicb_setmwfact(Display *disp, /* arg handling, manipulate mwfact */ if(!arg) mwfact = awesomeconf->mwfact; - else if(1 == sscanf(arg, "%lf", &delta)) + else if(sscanf(arg, "%lf", &delta)) { if(arg[0] != '+' && arg[0] != '-') mwfact = delta; diff --git a/layouts/tile.h b/layouts/tile.h index 4a0e7a4c3..e815915c8 100644 --- a/layouts/tile.h +++ b/layouts/tile.h @@ -5,7 +5,7 @@ #include -void uicb_incnmaster(Display *, awesome_config *, const char *); /* change number of master windows */ +void uicb_setnmaster(Display *, awesome_config *, const char *); /* change number of master windows */ void uicb_setmwfact(Display *, awesome_config *, const char *); /* sets master width factor */ void tile(Display *, awesome_config *); void tileleft(Display *, awesome_config *);