summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2017-01-07 17:21:28 +0100
committerAnselm R Garbe <anselm@garbe.us>2017-03-28 20:23:28 +0200
commit2952b68db88f38be8d34b80c7a7d2c7eb5b2484d (patch)
tree5f7c2ef09c6a78c1137c93aba455945046f088c6
parentapplied Markus' tagset purge of alternative view on _NET_ACTIVE_WINDOW event (diff)
downloaddwm-2952b68db88f38be8d34b80c7a7d2c7eb5b2484d.tar.gz
dwm-2952b68db88f38be8d34b80c7a7d2c7eb5b2484d.zip
cleanup
- unify multi-line expression alignment style. - unify multi-line function call alignment style. - simplify client moving on monitor count decrease. - clarify comment for focusin(). - remove old confusing comment about input focus fix in focusmon(). The explanation is already in the old commit message, so no need to keep it in the code. - remove old comment describing even older state of the code in focus(). - unify comment style. - break up some long lines. - fix some typos and grammar.
Diffstat (limited to '')
-rw-r--r--LICENSE2
-rw-r--r--config.def.h2
-rw-r--r--dwm.c64
3 files changed, 32 insertions, 36 deletions
diff --git a/LICENSE b/LICENSE
index 90121f5..fc41d77 100644
--- a/LICENSE
+++ b/LICENSE
@@ -16,7 +16,7 @@ MIT/X Consortium License
16© 2011 Christoph Lohmann <20h@r-36.net> 16© 2011 Christoph Lohmann <20h@r-36.net>
17© 2015-2016 Quentin Rameau <quinq@fifth.space> 17© 2015-2016 Quentin Rameau <quinq@fifth.space>
18© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com> 18© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
19© 2016 Markus Teich <markus.teich@stusta.mhn.de> 19© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
20 20
21Permission is hereby granted, free of charge, to any person obtaining a 21Permission is hereby granted, free of charge, to any person obtaining a
22copy of this software and associated documentation files (the "Software"), 22copy of this software and associated documentation files (the "Software"),
diff --git a/config.def.h b/config.def.h
index ba9a240..a9ac303 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,7 +15,7 @@ static const char col_cyan[] = "#005577";
15static const char *colors[][3] = { 15static const char *colors[][3] = {
16 /* fg bg border */ 16 /* fg bg border */
17 [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, 17 [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
18 [SchemeSel] = { col_gray4, col_cyan, col_cyan }, 18 [SchemeSel] = { col_gray4, col_cyan, col_cyan },
19}; 19};
20 20
21/* tagging */ 21/* tagging */
diff --git a/dwm.c b/dwm.c
index d27cb67..3f80b63 100644
--- a/dwm.c
+++ b/dwm.c
@@ -3,7 +3,7 @@
3 * 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
4 * 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
5 * manager selects for SubstructureRedirectMask on the root window, to receive 5 * manager selects for SubstructureRedirectMask on the root window, to receive
6 * events about window (dis-)appearance. Only one X connection at a time is 6 * events about window (dis-)appearance. Only one X connection at a time is
7 * allowed to select for this event mask. 7 * allowed to select for this event mask.
8 * 8 *
9 * The event handlers of dwm are organized in an array which is accessed 9 * The event handlers of dwm are organized in an array which is accessed
@@ -11,7 +11,7 @@
11 * in O(1) time. 11 * in O(1) time.
12 * 12 *
13 * Each child of the root window is called a client, except windows which have 13 * Each child of the root window is called a client, except windows which have
14 * set the override_redirect flag. Clients are organized in a linked client 14 * set the override_redirect flag. Clients are organized in a linked client
15 * list on each monitor, the focus history is remembered through a stack list 15 * list on each monitor, the focus history is remembered through a stack list
16 * on each monitor. Each client contains a bit array to indicate the tags of a 16 * on each monitor. Each client contains a bit array to indicate the tags of a
17 * client. 17 * client.
@@ -517,7 +517,8 @@ clientmessage(XEvent *e)
517 if (!c) 517 if (!c)
518 return; 518 return;
519 if (cme->message_type == netatom[NetWMState]) { 519 if (cme->message_type == netatom[NetWMState]) {
520 if (cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) 520 if (cme->data.l[1] == netatom[NetWMFullscreen]
521 || cme->data.l[2] == netatom[NetWMFullscreen])
521 setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ 522 setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
522 || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); 523 || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
523 } else if (cme->message_type == netatom[NetActiveWindow]) { 524 } else if (cme->message_type == netatom[NetActiveWindow]) {
@@ -783,7 +784,6 @@ focus(Client *c)
783{ 784{
784 if (!c || !ISVISIBLE(c)) 785 if (!c || !ISVISIBLE(c))
785 for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); 786 for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
786 /* was if (selmon->sel) */
787 if (selmon->sel && selmon->sel != c) 787 if (selmon->sel && selmon->sel != c)
788 unfocus(selmon->sel, 0); 788 unfocus(selmon->sel, 0);
789 if (c) { 789 if (c) {
@@ -804,7 +804,7 @@ focus(Client *c)
804 drawbars(); 804 drawbars();
805} 805}
806 806
807/* there are some broken focus acquiring clients */ 807/* there are some broken focus acquiring clients needing extra handling */
808void 808void
809focusin(XEvent *e) 809focusin(XEvent *e)
810{ 810{
@@ -823,8 +823,7 @@ focusmon(const Arg *arg)
823 return; 823 return;
824 if ((m = dirtomon(arg->i)) == selmon) 824 if ((m = dirtomon(arg->i)) == selmon)
825 return; 825 return;
826 unfocus(selmon->sel, 0); /* s/1/0/ fixes input focus issues 826 unfocus(selmon->sel, 0);
827 in gedit and anjuta */
828 selmon = m; 827 selmon = m;
829 focus(NULL); 828 focus(NULL);
830} 829}
@@ -961,7 +960,7 @@ grabkeys(void)
961 if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) 960 if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
962 for (j = 0; j < LENGTH(modifiers); j++) 961 for (j = 0; j < LENGTH(modifiers); j++)
963 XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, 962 XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
964 True, GrabModeAsync, GrabModeAsync); 963 True, GrabModeAsync, GrabModeAsync);
965 } 964 }
966} 965}
967 966
@@ -1151,7 +1150,7 @@ movemouse(const Arg *arg)
1151 ocx = c->x; 1150 ocx = c->x;
1152 ocy = c->y; 1151 ocy = c->y;
1153 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, 1152 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
1154 None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess) 1153 None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess)
1155 return; 1154 return;
1156 if (!getrootptr(&x, &y)) 1155 if (!getrootptr(&x, &y))
1157 return; 1156 return;
@@ -1434,7 +1433,7 @@ setclientstate(Client *c, long state)
1434 long data[] = { state, None }; 1433 long data[] = { state, None };
1435 1434
1436 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, 1435 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
1437 PropModeReplace, (unsigned char *)data, 2); 1436 PropModeReplace, (unsigned char *)data, 2);
1438} 1437}
1439 1438
1440int 1439int
@@ -1516,7 +1515,7 @@ setlayout(const Arg *arg)
1516 drawbar(selmon); 1515 drawbar(selmon);
1517} 1516}
1518 1517
1519/* arg > 1.0 will set mfact absolutly */ 1518/* arg > 1.0 will set mfact absolutely */
1520void 1519void
1521setmfact(const Arg *arg) 1520setmfact(const Arg *arg)
1522{ 1521{
@@ -1581,19 +1580,20 @@ setup(void)
1581 /* supporting window for NetWMCheck */ 1580 /* supporting window for NetWMCheck */
1582 wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); 1581 wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
1583 XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, 1582 XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
1584 PropModeReplace, (unsigned char *) &wmcheckwin, 1); 1583 PropModeReplace, (unsigned char *) &wmcheckwin, 1);
1585 XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8, 1584 XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8,
1586 PropModeReplace, (unsigned char *) "dwm", 4); 1585 PropModeReplace, (unsigned char *) "dwm", 4);
1587 XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32, 1586 XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32,
1588 PropModeReplace, (unsigned char *) &wmcheckwin, 1); 1587 PropModeReplace, (unsigned char *) &wmcheckwin, 1);
1589 /* EWMH support per view */ 1588 /* EWMH support per view */
1590 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, 1589 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
1591 PropModeReplace, (unsigned char *) netatom, NetLast); 1590 PropModeReplace, (unsigned char *) netatom, NetLast);
1592 XDeleteProperty(dpy, root, netatom[NetClientList]); 1591 XDeleteProperty(dpy, root, netatom[NetClientList]);
1593 /* select for events */ 1592 /* select events */
1594 wa.cursor = cursor[CurNormal]->cursor; 1593 wa.cursor = cursor[CurNormal]->cursor;
1595 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask 1594 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
1596 |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; 1595 |ButtonPressMask|PointerMotionMask|EnterWindowMask
1596 |LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
1597 XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); 1597 XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
1598 XSelectInput(dpy, root, wa.event_mask); 1598 XSelectInput(dpy, root, wa.event_mask);
1599 grabkeys(); 1599 grabkeys();
@@ -1769,12 +1769,11 @@ unmanage(Client *c, int destroyed)
1769 Monitor *m = c->mon; 1769 Monitor *m = c->mon;
1770 XWindowChanges wc; 1770 XWindowChanges wc;
1771 1771
1772 /* The server grab construct avoids race conditions. */
1773 detach(c); 1772 detach(c);
1774 detachstack(c); 1773 detachstack(c);
1775 if (!destroyed) { 1774 if (!destroyed) {
1776 wc.border_width = c->oldbw; 1775 wc.border_width = c->oldbw;
1777 XGrabServer(dpy); 1776 XGrabServer(dpy); /* avoid race conditions */
1778 XSetErrorHandler(xerrordummy); 1777 XSetErrorHandler(xerrordummy);
1779 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ 1778 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
1780 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1779 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
@@ -1871,8 +1870,8 @@ updategeom(void)
1871 memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); 1870 memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
1872 XFree(info); 1871 XFree(info);
1873 nn = j; 1872 nn = j;
1874 if (n <= nn) { 1873 if (n <= nn) { /* new monitors available */
1875 for (i = 0; i < (nn - n); i++) { /* new monitors available */ 1874 for (i = 0; i < (nn - n); i++) {
1876 for (m = mons; m && m->next; m = m->next); 1875 for (m = mons; m && m->next; m = m->next);
1877 if (m) 1876 if (m)
1878 m->next = createmon(); 1877 m->next = createmon();
@@ -1881,8 +1880,8 @@ updategeom(void)
1881 } 1880 }
1882 for (i = 0, m = mons; i < nn && m; m = m->next, i++) 1881 for (i = 0, m = mons; i < nn && m; m = m->next, i++)
1883 if (i >= n 1882 if (i >= n
1884 || (unique[i].x_org != m->mx || unique[i].y_org != m->my 1883 || unique[i].x_org != m->mx || unique[i].y_org != m->my
1885 || unique[i].width != m->mw || unique[i].height != m->mh)) 1884 || unique[i].width != m->mw || unique[i].height != m->mh)
1886 { 1885 {
1887 dirty = 1; 1886 dirty = 1;
1888 m->num = i; 1887 m->num = i;
@@ -1892,13 +1891,11 @@ updategeom(void)
1892 m->mh = m->wh = unique[i].height; 1891 m->mh = m->wh = unique[i].height;
1893 updatebarpos(m); 1892 updatebarpos(m);
1894 } 1893 }
1895 } else { 1894 } else { /* less monitors available nn < n */
1896 /* less monitors available nn < n */
1897 for (i = nn; i < n; i++) { 1895 for (i = nn; i < n; i++) {
1898 for (m = mons; m && m->next; m = m->next); 1896 for (m = mons; m && m->next; m = m->next);
1899 while (m->clients) { 1897 while ((c = m->clients)) {
1900 dirty = 1; 1898 dirty = 1;
1901 c = m->clients;
1902 m->clients = c->next; 1899 m->clients = c->next;
1903 detachstack(c); 1900 detachstack(c);
1904 c->mon = mons; 1901 c->mon = mons;
@@ -1913,8 +1910,7 @@ updategeom(void)
1913 free(unique); 1910 free(unique);
1914 } else 1911 } else
1915#endif /* XINERAMA */ 1912#endif /* XINERAMA */
1916 /* default monitor setup */ 1913 { /* default monitor setup */
1917 {
1918 if (!mons) 1914 if (!mons)
1919 mons = createmon(); 1915 mons = createmon();
1920 if (mons->mw != sw || mons->mh != sh) { 1916 if (mons->mw != sw || mons->mh != sh) {
@@ -1988,7 +1984,7 @@ updatesizehints(Client *c)
1988 } else 1984 } else
1989 c->maxa = c->mina = 0.0; 1985 c->maxa = c->mina = 0.0;
1990 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh 1986 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
1991 && c->maxw == c->minw && c->maxh == c->minh); 1987 && c->maxw == c->minw && c->maxh == c->minh);
1992} 1988}
1993 1989
1994void 1990void
@@ -2082,8 +2078,8 @@ wintomon(Window w)
2082} 2078}
2083 2079
2084/* There's no way to check accesses to destroyed windows, thus those cases are 2080/* There's no way to check accesses to destroyed windows, thus those cases are
2085 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs 2081 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
2086 * default error handler, which may call exit. */ 2082 * default error handler, which may call exit. */
2087int 2083int
2088xerror(Display *dpy, XErrorEvent *ee) 2084xerror(Display *dpy, XErrorEvent *ee)
2089{ 2085{
@@ -2098,7 +2094,7 @@ xerror(Display *dpy, XErrorEvent *ee)
2098 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) 2094 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
2099 return 0; 2095 return 0;
2100 fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", 2096 fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
2101 ee->request_code, ee->error_code); 2097 ee->request_code, ee->error_code);
2102 return xerrorxlib(dpy, ee); /* may call exit */ 2098 return xerrorxlib(dpy, ee); /* may call exit */
2103} 2099}
2104 2100