view.c
changeset 650 f3b8c71a69d4
parent 644 1ed8c40dde36
child 651 b9f4efd21473
equal deleted inserted replaced
649:d6023e0f3cf9 650:f3b8c71a69d4
    67 	restack();
    67 	restack();
    68 }
    68 }
    69 
    69 
    70 void
    70 void
    71 dotile(void) {
    71 dotile(void) {
    72 	unsigned int i, n, mpw, th;
    72 	unsigned int i, n, mw, mh, tw, th;
    73 	Client *c;
    73 	Client *c;
    74 
    74 
    75 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    75 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    76 		n++;
    76 		n++;
    77 	mpw = (waw * master) / 1000;
    77 	/* window geoms */
       
    78 	mw = (n > nmaster) ? (waw * master) / 1000 : waw;
       
    79 	mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
       
    80 	tw = waw - mw;
       
    81 	th = (n > nmaster) ? wah / (n - nmaster) : 0;
    78 
    82 
    79 	for(i = 0, c = clients; c; c = c->next)
    83 	for(i = 0, c = clients; c; c = c->next)
    80 		if(isvisible(c)) {
    84 		if(isvisible(c)) {
    81 			if(c->isfloat) {
    85 			if(c->isfloat) {
    82 				resize(c, True, TopLeft);
    86 				resize(c, True, TopLeft);
    83 				continue;
    87 				continue;
    84 			}
    88 			}
    85 			c->ismax = False;
    89 			c->ismax = False;
    86 			c->x = wax;
    90 			c->x = wax;
    87 			c->y = way;
    91 			c->y = way;
    88 			if(n == 1) { /* only 1 window */
    92 			if(i < nmaster) {
    89 				c->w = waw - 2 * BORDERPX;
    93 				c->y += i * mh;
    90 				c->h = wah - 2 * BORDERPX;
    94 				c->w = mw - 2 * BORDERPX;
    91 			}
    95 				c->h = mh - 2 * BORDERPX;
    92 			else if(i == 0) { /* master window */
       
    93 				c->w = mpw - 2 * BORDERPX;
       
    94 				c->h = wah - 2 * BORDERPX;
       
    95 				th = wah / (n - 1);
       
    96 			}
    96 			}
    97 			else {  /* tile window */
    97 			else {  /* tile window */
    98 				c->x += mpw;
    98 				c->x += mw;
    99 				c->w = (waw - mpw) - 2 * BORDERPX;
    99 				c->w = tw - 2 * BORDERPX;
   100 				if(th > bh) {
   100 				if(th > bh) {
   101 					c->y += (i - 1) * th;
   101 					c->y += (i - nmaster) * th;
   102 					c->h = th - 2 * BORDERPX;
   102 					c->h = th - 2 * BORDERPX;
   103 				}
   103 				}
   104 				else /* fallback if th < bh */
   104 				else /* fallback if th < bh */
   105 					c->h = wah - 2 * BORDERPX;
   105 					c->h = wah - 2 * BORDERPX;
   106 			}
   106 			}
   145 		focus(c);
   145 		focus(c);
   146 		restack();
   146 		restack();
   147 	}
   147 	}
   148 }
   148 }
   149 
   149 
       
   150 void
       
   151 incnmaster(Arg *arg) {
       
   152 	if(nmaster + arg->i < 1)
       
   153 		return;
       
   154 	nmaster += arg->i;
       
   155 	arrange();
       
   156 }
       
   157 
   150 Bool
   158 Bool
   151 isvisible(Client *c) {
   159 isvisible(Client *c) {
   152 	unsigned int i;
   160 	unsigned int i;
   153 
   161 
   154 	for(i = 0; i < ntags; i++)
   162 	for(i = 0; i < ntags; i++)
   238 	arrange();
   246 	arrange();
   239 }
   247 }
   240 
   248 
   241 void
   249 void
   242 zoom(Arg *arg) {
   250 zoom(Arg *arg) {
   243 	unsigned int n;
   251 	unsigned int i, n;
   244 	Client *c;
   252 	Client *c;
   245 
   253 
   246 	if(!sel)
   254 	if(!sel)
   247 		return;
   255 		return;
   248 	if(sel->isfloat || (arrange == dofloat)) {
   256 	if(sel->isfloat || (arrange == dofloat)) {
   249 		togglemax(sel);
   257 		togglemax(sel);
   250 		return;
   258 		return;
   251 	}
   259 	}
   252 	for(n = 0, c = clients; c; c = c->next)
   260 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
   253 		if(isvisible(c) && !c->isfloat)
   261 		n++;
   254 			n++;
   262 	if(n <= nmaster || (arrange == dofloat))
   255 	if(n < 2 || (arrange == dofloat))
   263 		return;
   256 		return;
   264 
   257 	if((c = sel) == nexttiled(clients))
   265 	for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
   258 		if(!(c = nexttiled(c->next)))
   266 		i++;
   259 			return;
   267 	if(c == sel && i < nmaster)
       
   268 		for(; c && i < nmaster; c = nexttiled(c->next))
       
   269 			i++;
       
   270 	if(!c)
       
   271 		return;
       
   272 
   260 	detach(c);
   273 	detach(c);
   261 	if(clients)
   274 	if(clients)
   262 		clients->prev = c;
   275 		clients->prev = c;
   263 	c->next = clients;
   276 	c->next = clients;
   264 	clients = c;
   277 	clients = c;