dwm.c
changeset 1098 25eea166210d
parent 1097 7241740da6ed
child 1099 5b4e2e1aba85
equal deleted inserted replaced
1097:7241740da6ed 1098:25eea166210d
  1274 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1274 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1275 	Monitor *m;
  1275 	Monitor *m;
  1276 	XWindowChanges wc;
  1276 	XWindowChanges wc;
  1277 
  1277 
  1278 	m = c->monitor;
  1278 	m = c->monitor;
  1279 
       
  1280 	if(sizehints) {
  1279 	if(sizehints) {
  1281 		/* set minimum possible */
  1280 		/* set minimum possible */
  1282 		if (w < 1)
  1281 		if (w < 1)
  1283 			w = 1;
  1282 			w = 1;
  1284 		if (h < 1)
  1283 		if (h < 1)
  1323 		y = m->sh - h - 2 * c->border;
  1322 		y = m->sh - h - 2 * c->border;
  1324 	if(x + w + 2 * c->border < m->sx)
  1323 	if(x + w + 2 * c->border < m->sx)
  1325 		x = m->sx;
  1324 		x = m->sx;
  1326 	if(y + h + 2 * c->border < m->sy)
  1325 	if(y + h + 2 * c->border < m->sy)
  1327 		y = m->sy;
  1326 		y = m->sy;
       
  1327 	fprintf(stderr, "resize %d %d %d %d (%d %d %d %d)\n", x, y , w, h, m->sx, m->sy, m->sw, m->sh);
  1328 	if(c->x != x || c->y != y || c->w != w || c->h != h) {
  1328 	if(c->x != x || c->y != y || c->w != w || c->h != h) {
  1329 		c->x = wc.x = x;
  1329 		c->x = wc.x = x;
  1330 		c->y = wc.y = y;
  1330 		c->y = wc.y = y;
  1331 		c->w = wc.width = w;
  1331 		c->w = wc.width = w;
  1332 		c->h = wc.height = h;
  1332 		c->h = wc.height = h;
  1603 	for(i = 0; i < mcount; i++) {
  1603 	for(i = 0; i < mcount; i++) {
  1604 		/* init geometry */
  1604 		/* init geometry */
  1605 		m = &monitors[i];
  1605 		m = &monitors[i];
  1606 		m->id = i;
  1606 		m->id = i;
  1607 
  1607 
  1608 		if (mcount != 1 && isxinerama) {
  1608 		if(mcount != 1 && isxinerama) {
  1609 			m->sx = info[i].x_org;
  1609 			m->sx = info[i].x_org;
  1610 			m->sy = info[i].y_org;
  1610 			m->sy = info[i].y_org;
  1611 			m->sw = info[i].width;
  1611 			m->sw = info[i].width;
  1612 			m->sh = info[i].height;
  1612 			m->sh = info[i].height;
  1613 			fprintf(stderr, "monitor[%d]: %d,%d,%d,%d\n", i, m->sx, m->sy, m->sw, m->sh);
  1613 			fprintf(stderr, "monitor[%d]: %d,%d,%d,%d\n", i, m->sx, m->sy, m->sw, m->sh);
  1725 tile(Monitor *m) {
  1725 tile(Monitor *m) {
  1726 	unsigned int i, n, nx, ny, nw, nh, mw, th;
  1726 	unsigned int i, n, nx, ny, nw, nh, mw, th;
  1727 	Client *c, *mc;
  1727 	Client *c, *mc;
  1728 
  1728 
  1729 	domwfact = dozoom = True;
  1729 	domwfact = dozoom = True;
  1730 
  1730 	nx = m->wax;
  1731 	nx = ny = nw = 0; /* gcc stupidity requires this */
  1731 	ny = m->way;
  1732 
  1732 	nw = 0;
  1733 	for(n = 0, c = nexttiled(clients, m); c; c = nexttiled(c->next, m))
  1733 	for(n = 0, c = nexttiled(clients, m); c; c = nexttiled(c->next, m))
  1734 		n++;
  1734 		n++;
  1735 
  1735 
  1736 	/* window geoms */
  1736 	/* window geoms */
  1737 	mw = (n == 1) ? m->waw : m->mwfact * m->waw;
  1737 	mw = (n == 1) ? m->waw : m->mwfact * m->waw;
  1755 			if(i + 1 == n) /* remainder */
  1755 			if(i + 1 == n) /* remainder */
  1756 				nh = (m->way + m->wah) - ny - 2 * c->border;
  1756 				nh = (m->way + m->wah) - ny - 2 * c->border;
  1757 			else
  1757 			else
  1758 				nh = th - 2 * c->border;
  1758 				nh = th - 2 * c->border;
  1759 		}
  1759 		}
       
  1760 		fprintf(stderr, "tile %d %d %d %d\n", nx, ny, nw, nh);
  1760 		resize(c, nx, ny, nw, nh, RESIZEHINTS);
  1761 		resize(c, nx, ny, nw, nh, RESIZEHINTS);
  1761 		if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
  1762 		if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
  1762 			/* client doesn't accept size constraints */
  1763 			/* client doesn't accept size constraints */
  1763 			resize(c, nx, ny, nw, nh, False);
  1764 			resize(c, nx, ny, nw, nh, False);
  1764 		if(n > 1 && th != m->wah)
  1765 		if(n > 1 && th != m->wah)
  1765 			ny = c->y + c->h + 2 * c->border;
  1766 			ny = c->y + c->h + 2 * c->border;
  1766 
       
  1767 		i++;
  1767 		i++;
  1768 	}
  1768 	}
  1769 }
  1769 }
       
  1770 
  1770 void
  1771 void
  1771 togglebar(const char *arg) {
  1772 togglebar(const char *arg) {
  1772 	if(bpos == BarOff)
  1773 	if(bpos == BarOff)
  1773 		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
  1774 		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
  1774 	else
  1775 	else
  1822 	c->isbanned = False;
  1823 	c->isbanned = False;
  1823 }
  1824 }
  1824 
  1825 
  1825 void
  1826 void
  1826 unmanage(Client *c) {
  1827 unmanage(Client *c) {
       
  1828 	Monitor *m = c->monitor;
  1827 	XWindowChanges wc;
  1829 	XWindowChanges wc;
  1828 
  1830 
  1829 	wc.border_width = c->oldborder;
  1831 	wc.border_width = c->oldborder;
  1830 	/* The server grab construct avoids race conditions. */
  1832 	/* The server grab construct avoids race conditions. */
  1831 	XGrabServer(dpy);
  1833 	XGrabServer(dpy);
  1840 	free(c->tags);
  1842 	free(c->tags);
  1841 	free(c);
  1843 	free(c);
  1842 	XSync(dpy, False);
  1844 	XSync(dpy, False);
  1843 	XSetErrorHandler(xerror);
  1845 	XSetErrorHandler(xerror);
  1844 	XUngrabServer(dpy);
  1846 	XUngrabServer(dpy);
  1845 	arrange(NULL);
  1847 	arrange(m);
  1846 }
  1848 }
  1847 
  1849 
  1848 void
  1850 void
  1849 unmapnotify(XEvent *e) {
  1851 unmapnotify(XEvent *e) {
  1850 	Client *c;
  1852 	Client *c;