diff --git a/layouts/tile.c b/layouts/tile.c index b8fa8c2f..79be282e 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -36,6 +36,8 @@ uicb_tag_setnmaster(int screen, char * arg) { Tag **curtags = tags_get_current(screen); Layout *curlay = curtags[0]->layout; + Client *c; + int n; if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft @@ -46,6 +48,13 @@ uicb_tag_setnmaster(int screen, char * arg) if((curtags[0]->nmaster = (int) compute_new_value_from_arg(arg, (double) curtags[0]->nmaster)) < 0) curtags[0]->nmaster = 0; + for(n = 0, c = globalconf.clients; c; c = c->next) + if(IS_TILED(c, screen)) + n++; + + if(curtags[0]->nmaster > n - 1) + curtags[0]->nmaster = n; + p_delete(&curtags); globalconf.screens[screen].need_arrange = True; @@ -56,6 +65,8 @@ uicb_tag_setncol(int screen, char * arg) { Tag **curtags = tags_get_current(screen); Layout *curlay = curtags[0]->layout; + Client *c; + int n; if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft @@ -63,9 +74,17 @@ uicb_tag_setncol(int screen, char * arg) && curlay->arrange != layout_tiletop)) return; + if((curtags[0]->ncol = (int) compute_new_value_from_arg(arg, (double) curtags[0]->ncol)) < 1) curtags[0]->ncol = 1; + for(n = 0, c = globalconf.clients; c; c = c->next) + if(IS_TILED(c, screen)) + n++; + + if(curtags[0]->ncol > n - 1) + curtags[0]->ncol = n - 1; + p_delete(&curtags); globalconf.screens[screen].need_arrange = True;