dwm.c
changeset 1227 1f0e2de78c35
parent 1226 6830cb2bbecf
child 1228 b5b7a1d8dc4f
equal deleted inserted replaced
1226:6830cb2bbecf 1227:1f0e2de78c35
   154 void killclient(const void *arg);
   154 void killclient(const void *arg);
   155 void manage(Window w, XWindowAttributes *wa);
   155 void manage(Window w, XWindowAttributes *wa);
   156 void mappingnotify(XEvent *e);
   156 void mappingnotify(XEvent *e);
   157 void maprequest(XEvent *e);
   157 void maprequest(XEvent *e);
   158 void movemouse(Client *c);
   158 void movemouse(Client *c);
   159 Client *nextunfloating(Client *c);
   159 Client *nexttiled(Client *c);
   160 void propertynotify(XEvent *e);
   160 void propertynotify(XEvent *e);
   161 void quit(const void *arg);
   161 void quit(const void *arg);
   162 void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
   162 void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
   163 void resizemouse(Client *c);
   163 void resizemouse(Client *c);
   164 void restack(void);
   164 void restack(void);
  1049 		}
  1049 		}
  1050 	}
  1050 	}
  1051 }
  1051 }
  1052 
  1052 
  1053 Client *
  1053 Client *
  1054 nextunfloating(Client *c) {
  1054 nexttiled(Client *c) {
  1055 	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
  1055 	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
  1056 	return c;
  1056 	return c;
  1057 }
  1057 }
  1058 
  1058 
  1059 void
  1059 void
  1462 tile(void) {
  1462 tile(void) {
  1463 	int x, y, h, w;
  1463 	int x, y, h, w;
  1464 	uint i, n;
  1464 	uint i, n;
  1465 	Client *c;
  1465 	Client *c;
  1466 
  1466 
  1467 	for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++);
  1467 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
  1468 	if(n == 0)
  1468 	if(n == 0)
  1469 		return;
  1469 		return;
  1470 
  1470 
  1471 	/* master */
  1471 	/* master */
  1472 	c = nextunfloating(clients);
  1472 	c = nexttiled(clients);
  1473 
  1473 
  1474 	if(n == 1)
  1474 	if(n == 1)
  1475 		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
  1475 		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
  1476 	else
  1476 	else
  1477 		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
  1477 		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
  1485 	w = (tx > c->x + c->w) ? wx + ww - x : tw;
  1485 	w = (tx > c->x + c->w) ? wx + ww - x : tw;
  1486 	h = th / n;
  1486 	h = th / n;
  1487 	if(h < bh)
  1487 	if(h < bh)
  1488 		h = th;
  1488 		h = th;
  1489 
  1489 
  1490 	for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) {
  1490 	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
  1491 		if(i + 1 == n) /* remainder */
  1491 		if(i + 1 == n) /* remainder */
  1492 			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
  1492 			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
  1493 		else
  1493 		else
  1494 			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
  1494 			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
  1495 		if(h != th)
  1495 		if(h != th)
  1787 
  1787 
  1788 void
  1788 void
  1789 zoom(const void *arg) {
  1789 zoom(const void *arg) {
  1790 	Client *c = sel;
  1790 	Client *c = sel;
  1791 
  1791 
  1792 	if(c == nextunfloating(clients))
  1792 	if(!lt->arrange || sel->isfloating)
  1793 		if(!c || !(c = nextunfloating(c->next)))
  1793 		return;
       
  1794 	if(c == nexttiled(clients))
       
  1795 		if(!c || !(c = nexttiled(c->next)))
  1794 			return;
  1796 			return;
  1795 	if(lt->arrange == tile && !sel->isfloating) {
  1797 	detach(c);
  1796 		detach(c);
  1798 	attach(c);
  1797 		attach(c);
  1799 	focus(c);
  1798 		focus(c);
       
  1799 	}
       
  1800 	arrange();
  1800 	arrange();
  1801 }
  1801 }
  1802 
  1802 
  1803 int
  1803 int
  1804 main(int argc, char *argv[]) {
  1804 main(int argc, char *argv[]) {