From b7e379c2d0bb3ec461dd011b39fc2c0472857e87 Mon Sep 17 00:00:00 2001 From: Pasini Matthieu Date: Tue, 5 Feb 2008 20:36:50 +0900 Subject: [PATCH] tag_setncol and tag_setnmaster shouldn't go over the numbers of clients Signed-off-by: Julien Danjou --- layouts/tile.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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;