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