dwm.c
changeset 1130 b661ad410646
parent 1129 43d862bda73e
child 1132 a1c28da5bc91
equal deleted inserted replaced
1129:43d862bda73e 1130:b661ad410646
     1 /**
       
     2  * - allow for vstack
       
     3  */
       
     4 /* See LICENSE file for copyright and license details.
     1 /* See LICENSE file for copyright and license details.
     5  *
     2  *
     6  * dynamic window manager is designed like any other X client as well. It is
     3  * dynamic window manager is designed like any other X client as well. It is
     7  * driven through handling X events. In contrast to other X clients, a window
     4  * driven through handling X events. In contrast to other X clients, a window
     8  * manager selects for SubstructureRedirectMask on the root window, to receive
     5  * manager selects for SubstructureRedirectMask on the root window, to receive
    34 #include <string.h>
    31 #include <string.h>
    35 #include <unistd.h>
    32 #include <unistd.h>
    36 #include <sys/select.h>
    33 #include <sys/select.h>
    37 #include <sys/types.h>
    34 #include <sys/types.h>
    38 #include <sys/wait.h>
    35 #include <sys/wait.h>
    39 #include <regex.h>
       
    40 #include <X11/cursorfont.h>
    36 #include <X11/cursorfont.h>
    41 #include <X11/keysym.h>
    37 #include <X11/keysym.h>
    42 #include <X11/Xatom.h>
    38 #include <X11/Xatom.h>
    43 #include <X11/Xlib.h>
    39 #include <X11/Xlib.h>
    44 #include <X11/Xproto.h>
    40 #include <X11/Xproto.h>
   168 void setup(void);
   164 void setup(void);
   169 void spawn(const char *arg);
   165 void spawn(const char *arg);
   170 void tag(const char *arg);
   166 void tag(const char *arg);
   171 unsigned int textnw(const char *text, unsigned int len);
   167 unsigned int textnw(const char *text, unsigned int len);
   172 unsigned int textw(const char *text);
   168 unsigned int textw(const char *text);
   173 void tile(void);
   169 void tileh(void);
       
   170 void tilehstack(unsigned int n);
   174 unsigned int tilemaster(void);
   171 unsigned int tilemaster(void);
       
   172 void tilev(void);
   175 void tilevstack(unsigned int n);
   173 void tilevstack(unsigned int n);
   176 void togglefloating(const char *arg);
   174 void togglefloating(const char *arg);
   177 void toggletag(const char *arg);
   175 void toggletag(const char *arg);
   178 void toggleview(const char *arg);
   176 void toggleview(const char *arg);
   179 void unban(Client *c);
   177 void unban(Client *c);
  1545 	if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
  1543 	if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
  1546 		/* client doesn't accept size constraints */
  1544 		/* client doesn't accept size constraints */
  1547 		resize(c, x, y, w, h, False);
  1545 		resize(c, x, y, w, h, False);
  1548 }
  1546 }
  1549 
  1547 
       
  1548 void
       
  1549 tileh(void) {
       
  1550 	tilehstack(tilemaster());
       
  1551 }
       
  1552 
       
  1553 void
       
  1554 tilehstack(unsigned int n) {
       
  1555 	int i, x, w;
       
  1556 	Client *c;
       
  1557 
       
  1558 	if(n == 0)
       
  1559 		return;
       
  1560 
       
  1561 	x = TX;
       
  1562 	w = (TW) / n;
       
  1563 	if(w < bh)
       
  1564 		w = TW;
       
  1565 
       
  1566 	for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++)
       
  1567 		if(i > 0) {
       
  1568 			if(i > 1 && i == n) /* remainder */
       
  1569 				tileresize(c, x, TY, ((TX) + (TW)) - x - 2 * c->border,
       
  1570 				              TH - 2 * c->border);
       
  1571 			else
       
  1572 				tileresize(c, x, TY, w - 2 * c->border,
       
  1573 				              TH - 2 * c->border);
       
  1574 			if(w != TW)
       
  1575 				x = c->x + c->w + 2 * c->border;
       
  1576 		}
       
  1577 }
       
  1578 
  1550 unsigned int
  1579 unsigned int
  1551 tilemaster(void) {
  1580 tilemaster(void) {
  1552 	unsigned int n;
  1581 	unsigned int n;
  1553 	Client *c, *mc;
  1582 	Client *c, *mc;
  1554 
  1583 
  1559 	if(n == 1)
  1588 	if(n == 1)
  1560 		tileresize(mc, MOX, MOY, (MOW) - 2 * mc->border, (MOH) - 2 * mc->border);
  1589 		tileresize(mc, MOX, MOY, (MOW) - 2 * mc->border, (MOH) - 2 * mc->border);
  1561 	else
  1590 	else
  1562 		tileresize(mc, MX, MY, (MW) - 2 * mc->border, (MH) - 2 * mc->border);
  1591 		tileresize(mc, MX, MY, (MW) - 2 * mc->border, (MH) - 2 * mc->border);
  1563 	return n - 1;
  1592 	return n - 1;
       
  1593 }
       
  1594 
       
  1595 void
       
  1596 tilev(void) {
       
  1597 	tilevstack(tilemaster());
  1564 }
  1598 }
  1565 
  1599 
  1566 void
  1600 void
  1567 tilevstack(unsigned int n) {
  1601 tilevstack(unsigned int n) {
  1568 	int i, y, h;
  1602 	int i, y, h;
  1585 				tileresize(c, TX, y, (TW) - 2 * c->border,
  1619 				tileresize(c, TX, y, (TW) - 2 * c->border,
  1586 				              h - 2 * c->border);
  1620 				              h - 2 * c->border);
  1587 			if(h != TH)
  1621 			if(h != TH)
  1588 				y = c->y + c->h + 2 * c->border;
  1622 				y = c->y + c->h + 2 * c->border;
  1589 		}
  1623 		}
  1590 }
       
  1591 
       
  1592 void
       
  1593 tile(void) {
       
  1594 	tilevstack(tilemaster());
       
  1595 }
  1624 }
  1596 
  1625 
  1597 void
  1626 void
  1598 togglefloating(const char *arg) {
  1627 togglefloating(const char *arg) {
  1599 	if(!sel)
  1628 	if(!sel)