removed some empty lines 5dd92c76
Anselm R Garbe · 2009-07-02 18:40 1 file(s) · +6 −43
dwm.c +6 −43
330 330
		*h = bh;
331 331
	if(*w < bh)
332 332
		*w = bh;
333 -
334 333
	if(resizehints || c->isfloating) {
335 334
		/* see last two sentences in ICCCM 4.1.2.3 */
336 335
		baseismin = c->basew == c->minw && c->baseh == c->minh;
337 -
338 336
		if(!baseismin) { /* temporarily remove base dimensions */
339 337
			*w -= c->basew;
340 338
			*h -= c->baseh;
341 339
		}
342 -
343 340
		/* adjust for aspect limits */
344 341
		if(c->mina > 0 && c->maxa > 0) {
345 342
			if(c->maxa < (float)*w / *h)
347 344
			else if(c->mina < (float)*h / *w)
348 345
				*h = *w * c->mina;
349 346
		}
350 -
351 347
		if(baseismin) { /* increment calculation requires this */
352 348
			*w -= c->basew;
353 349
			*h -= c->baseh;
354 350
		}
355 -
356 351
		/* adjust for increment value */
357 352
		if(c->incw)
358 353
			*w -= *w % c->incw;
359 354
		if(c->inch)
360 355
			*h -= *h % c->inch;
361 -
362 356
		/* restore base dimensions */
363 357
		*w += c->basew;
364 358
		*h += c->baseh;
365 -
366 359
		*w = MAX(*w, c->minw);
367 360
		*h = MAX(*h, c->minh);
368 -
369 361
		if(c->maxw)
370 362
			*w = MIN(*w, c->maxw);
371 -
372 363
		if(c->maxh)
373 364
			*h = MIN(*h, c->maxh);
374 365
	}
438 429
		focus(c);
439 430
		click = ClkClientWin;
440 431
	}
441 -
442 432
	for(i = 0; i < LENGTH(buttons); i++)
443 433
		if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
444 434
		   && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
449 439
checkotherwm(void) {
450 440
	otherwm = False;
451 441
	xerrorxlib = XSetErrorHandler(xerrorstart);
452 -
453 442
	/* this causes an error if some other window manager is running */
454 443
	XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
455 444
	XSync(dpy, False);
644 633
		if(c->isurgent)
645 634
			urg |= c->tags;
646 635
	}
647 -
648 636
	dc.x = 0;
649 637
	if(mons->next) { /* more than a single monitor */
650 638
		dc.w = TEXTW(monsyms[m->screen_number]);
676 664
		}
677 665
		drawtext(stext, dc.norm, False);
678 666
	}
679 -
	else {
667 +
	else
680 668
		dc.x = m->ww;
681 -
	}
682 669
	if((dc.w = dc.x - x) > bh) {
683 670
		dc.x = x;
684 671
		if(m->sel) {
860 847
	int di;
861 848
	unsigned int dui;
862 849
	Window dummy;
850 +
863 851
	return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
864 852
}
865 853
931 919
void
932 920
grabkeys(void) {
933 921
	updatenumlockmask();
934 -
	{ /* grab keys */
922 +
	{
935 923
		unsigned int i, j;
936 924
		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
937 925
		KeyCode code;
1050 1038
		die("fatal: could not malloc() %u bytes\n", sizeof(Client));
1051 1039
	*c = cz;
1052 1040
	c->win = w;
1053 -
1054 1041
	if(XGetTransientForHint(dpy, w, &trans))
1055 1042
		t = wintoclient(trans);
1056 1043
	if(t) {
1061 1048
		c->mon = selmon;
1062 1049
		applyrules(c);
1063 1050
	}
1064 -
1065 1051
	/* geometry */
1066 1052
	c->x = wa->x + c->mon->wx;
1067 1053
	c->y = wa->y + c->mon->wy;
1084 1070
		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
1085 1071
		c->bw = borderpx;
1086 1072
	}
1087 -
1088 1073
	wc.border_width = c->bw;
1089 1074
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
1090 1075
	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
1290 1275
		case MotionNotify:
1291 1276
			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
1292 1277
			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1293 -
1294 1278
			if(snap && nw >= selmon->wx && nw <= selmon->wx + selmon->ww
1295 1279
			        && nh >= selmon->wy && nh <= selmon->wy + selmon->wh) {
1296 1280
				if(!c->isfloating && lt[selmon->sellt]->arrange
1440 1424
	lt[0] = &layouts[0];
1441 1425
	lt[1] = &layouts[1 % LENGTH(layouts)];
1442 1426
	updategeom();
1443 -
1444 1427
	/* init atoms */
1445 1428
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
1446 1429
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
1447 1430
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
1448 1431
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
1449 1432
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
1450 -
1451 1433
	/* init cursors */
1452 1434
	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
1453 1435
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
1454 1436
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
1455 -
1456 1437
	/* init appearance */
1457 1438
	dc.norm[ColBorder] = getcolor(normbordercolor);
1458 1439
	dc.norm[ColBG] = getcolor(normbgcolor);
1465 1446
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
1466 1447
	if(!dc.font.set)
1467 1448
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
1468 -
1469 1449
	/* init bars */
1470 1450
	for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
1471 1451
		w = TEXTW(layouts[i].symbol);
1473 1453
	}
1474 1454
	updatebars();
1475 1455
	updatestatus();
1476 -
1477 1456
	/* EWMH support per view */
1478 1457
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
1479 1458
			PropModeReplace, (unsigned char *) netatom, NetLast);
1480 -
1481 1459
	/* select for events */
1482 1460
	wa.cursor = cursor[CurNormal];
1483 1461
	wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
1485 1463
			|PropertyChangeMask;
1486 1464
	XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
1487 1465
	XSelectInput(dpy, root, wa.event_mask);
1488 -
1489 1466
	grabkeys();
1490 1467
}
1491 1468
1562 1539
	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
1563 1540
	if(n == 0)
1564 1541
		return;
1565 -
1566 1542
	/* master */
1567 1543
	c = nexttiled(m->clients);
1568 1544
	mw = m->mfact * m->ww;
1569 1545
	resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
1570 -
1571 1546
	if(--n == 0)
1572 1547
		return;
1573 -
1574 1548
	/* tile stack */
1575 1549
	x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw;
1576 1550
	y = m->wy;
1578 1552
	h = m->wh / n;
1579 1553
	if(h < bh)
1580 1554
		h = m->wh;
1581 -
1582 1555
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1583 1556
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1584 1557
		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
1612 1585
1613 1586
	if(!selmon->sel)
1614 1587
		return;
1615 -
	
1616 1588
	mask = selmon->sel->tags ^ (arg->ui & TAGMASK);
1617 1589
	if(mask) {
1618 1590
		selmon->sel->tags = mask;
1677 1649
	wa.override_redirect = True;
1678 1650
	wa.background_pixmap = ParentRelative;
1679 1651
	wa.event_mask = ButtonPressMask|ExposureMask;
1680 -
1681 1652
	for(m = mons; m; m = m->next) {
1682 1653
		m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
1683 -
1684 1654
		                          CopyFromParent, DefaultVisual(dpy, screen),
1685 1655
		                          CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
1686 1656
		XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
1719 1689
		m->next = newmons;
1720 1690
		newmons = m;
1721 1691
	}
1722 -
1723 1692
	/* initialise monitor(s) */
1724 1693
#ifdef XINERAMA
1725 1694
	if(XineramaIsActive(dpy)) {
1742 1711
		m->mw = m->ww = sw;
1743 1712
		m->mh = m->wh = sh;
1744 1713
	}
1745 -
1746 1714
	/* bar geometry setup */
1747 1715
	for(m = newmons; m; m = m->next) {
1748 1716
		m->sel = m->stack = m->clients = NULL;
1754 1722
		m->topbar = TOPBAR;
1755 1723
		updatebarpos(m);
1756 1724
	}
1757 -
1758 1725
	/* reassign left over clients of disappeared monitors */
1759 1726
	for(tm = mons; tm; tm = tm->next)
1760 1727
		while(tm->clients) {
1765 1732
			attach(c);
1766 1733
			attachstack(c);
1767 1734
		}
1768 -
1769 1735
	/* select focused monitor */
1770 1736
	cleanupmons();
1771 1737
	selmon = mons = newmons;
1861 1827
		}
1862 1828
		else
1863 1829
			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
1864 -
1865 1830
		XFree(wmh);
1866 1831
	}
1867 1832
}
1941 1906
zoom(const Arg *arg) {
1942 1907
	Client *c = selmon->sel;
1943 1908
1944 -
	if(!lt[selmon->sellt]->arrange || lt[selmon->sellt]->arrange == monocle || (selmon->sel && selmon->sel->isfloating))
1909 +
	if(!lt[selmon->sellt]->arrange
1910 +
	|| lt[selmon->sellt]->arrange == monocle
1911 +
	|| (selmon->sel && selmon->sel->isfloating))
1945 1912
		return;
1946 1913
	if(c == nexttiled(selmon->clients))
1947 1914
		if(!c || !(c = nexttiled(c->next)))
1958 1925
		die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n");
1959 1926
	else if(argc != 1)
1960 1927
		die("usage: dwm [-v]\n");
1961 -
1962 1928
	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
1963 1929
		fputs("warning: no locale support\n", stderr);
1964 -
1965 1930
	if(!(dpy = XOpenDisplay(NULL)))
1966 1931
		die("dwm: cannot open display\n");
1967 -
1968 1932
	checkotherwm();
1969 1933
	setup();
1970 1934
	scan();
1971 1935
	run();
1972 1936
	cleanup();
1973 -
1974 1937
	XCloseDisplay(dpy);
1975 1938
	return 0;
1976 1939
}