dwm.c
changeset 1237 7af79b380a77
parent 1236 523ba822927f
child 1238 70a2c5f7c716
equal deleted inserted replaced
1236:523ba822927f 1237:7af79b380a77
   103 } Key;
   103 } Key;
   104 
   104 
   105 typedef struct {
   105 typedef struct {
   106 	const char *symbol;
   106 	const char *symbol;
   107 	void (*arrange)(void);
   107 	void (*arrange)(void);
   108 	void (*updategeom)(void);
       
   109 } Layout;
   108 } Layout;
   110 
   109 
   111 typedef struct {
   110 typedef struct {
   112 	const char *class;
   111 	const char *class;
   113 	const char *instance;
   112 	const char *instance;
   181 void unmanage(Client *c);
   180 void unmanage(Client *c);
   182 void unmapnotify(XEvent *e);
   181 void unmapnotify(XEvent *e);
   183 void updatebar(void);
   182 void updatebar(void);
   184 void updategeom(void);
   183 void updategeom(void);
   185 void updatesizehints(Client *c);
   184 void updatesizehints(Client *c);
   186 void updatetilegeom(void);
       
   187 void updatetitle(Client *c);
   185 void updatetitle(Client *c);
   188 void updatewmhints(Client *c);
   186 void updatewmhints(Client *c);
   189 void view(const void *arg);
   187 void view(const void *arg);
   190 void viewprevtag(const void *arg);
   188 void viewprevtag(const void *arg);
   191 int xerror(Display *dpy, XErrorEvent *ee);
   189 int xerror(Display *dpy, XErrorEvent *ee);
   195 
   193 
   196 /* variables */
   194 /* variables */
   197 char stext[256];
   195 char stext[256];
   198 int screen, sx, sy, sw, sh;
   196 int screen, sx, sy, sw, sh;
   199 int bx, by, bw, bh, blw, wx, wy, ww, wh;
   197 int bx, by, bw, bh, blw, wx, wy, ww, wh;
   200 int mx, my, mw, mh, tx, ty, tw, th;
       
   201 uint seltags = 0;
   198 uint seltags = 0;
   202 int (*xerrorxlib)(Display *, XErrorEvent *);
   199 int (*xerrorxlib)(Display *, XErrorEvent *);
   203 uint numlockmask = 0;
   200 uint numlockmask = 0;
   204 void (*handler[LASTEvent]) (XEvent *) = {
   201 void (*handler[LASTEvent]) (XEvent *) = {
   205 	[ButtonPress] = buttonpress,
   202 	[ButtonPress] = buttonpress,
  1313 		return;
  1310 		return;
  1314 	d = d < 1.0 ? d + mfact : d - 1.0;
  1311 	d = d < 1.0 ? d + mfact : d - 1.0;
  1315 	if(d < 0.1 || d > 0.9)
  1312 	if(d < 0.1 || d > 0.9)
  1316 		return;
  1313 		return;
  1317 	mfact = d;
  1314 	mfact = d;
  1318 	updatetilegeom();
       
  1319 	arrange();
  1315 	arrange();
  1320 }
  1316 }
  1321 
  1317 
  1322 void
  1318 void
  1323 setup(void) {
  1319 setup(void) {
  1437 	return XTextWidth(dc.font.xfont, text, len);
  1433 	return XTextWidth(dc.font.xfont, text, len);
  1438 }
  1434 }
  1439 
  1435 
  1440 void
  1436 void
  1441 tile(void) {
  1437 tile(void) {
  1442 	int x, y, h, w;
  1438 	int x, y, h, w, mx, my, mw, mh, tx, ty, tw, th;
  1443 	uint i, n;
  1439 	uint i, n;
  1444 	Client *c;
  1440 	Client *c;
  1445 
  1441 
  1446 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
  1442 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
  1447 	if(n == 0)
  1443 	if(n == 0)
  1448 		return;
  1444 		return;
       
  1445 
       
  1446 	/* master area geometry */
       
  1447 	mx = wx;
       
  1448 	my = wy;
       
  1449 	mw = mfact * ww;
       
  1450 	mh = wh;
       
  1451 
       
  1452 	/* tile area geometry */
       
  1453 	tx = mx + mw;
       
  1454 	ty = wy;
       
  1455 	tw = ww - mw;
       
  1456 	th = wh;
  1449 
  1457 
  1450 	/* master */
  1458 	/* master */
  1451 	c = nexttiled(clients);
  1459 	c = nexttiled(clients);
  1452 
  1460 
  1453 	if(n == 1)
  1461 	if(n == 1)
  1611 
  1619 
  1612 	/* bar geometry */
  1620 	/* bar geometry */
  1613 	bx = wx;
  1621 	bx = wx;
  1614 	by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
  1622 	by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
  1615 	bw = ww;
  1623 	bw = ww;
  1616 
       
  1617 	/* update layout geometries */
       
  1618 	for(i = 0; i < LENGTH(layouts); i++)
       
  1619 		if(layouts[i].updategeom)
       
  1620 			layouts[i].updategeom();
       
  1621 }
  1624 }
  1622 
  1625 
  1623 void
  1626 void
  1624 updatesizehints(Client *c) {
  1627 updatesizehints(Client *c) {
  1625 	long msize;
  1628 	long msize;
  1668 	}
  1671 	}
  1669 	else
  1672 	else
  1670 		c->minax = c->maxax = c->minay = c->maxay = 0;
  1673 		c->minax = c->maxax = c->minay = c->maxay = 0;
  1671 	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
  1674 	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
  1672 			&& c->maxw == c->minw && c->maxh == c->minh);
  1675 			&& c->maxw == c->minw && c->maxh == c->minh);
  1673 }
       
  1674 
       
  1675 void
       
  1676 updatetilegeom(void) {
       
  1677 	/* master area geometry */
       
  1678 	mx = wx;
       
  1679 	my = wy;
       
  1680 	mw = mfact * ww;
       
  1681 	mh = wh;
       
  1682 
       
  1683 	/* tile area geometry */
       
  1684 	tx = mx + mw;
       
  1685 	ty = wy;
       
  1686 	tw = ww - mw;
       
  1687 	th = wh;
       
  1688 }
  1676 }
  1689 
  1677 
  1690 void
  1678 void
  1691 updatetitle(Client *c) {
  1679 updatetitle(Client *c) {
  1692 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
  1680 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))