| 3 |
3 |
|
* dynamic window manager is designed like any other X client as well. It is |
| 4 |
4 |
|
* driven through handling X events. In contrast to other X clients, a window |
| 5 |
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 |
7 |
|
* allowed to select for this event mask. |
| 8 |
8 |
|
* |
| 9 |
9 |
|
* The event handlers of dwm are organized in an array which is accessed |
|
| 11 |
11 |
|
* in O(1) time. |
| 12 |
12 |
|
* |
| 13 |
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 |
15 |
|
* list on each monitor, the focus history is remembered through a stack list |
| 16 |
16 |
|
* on each monitor. Each client contains a bit array to indicate the tags of a |
| 17 |
17 |
|
* client. |
|
| 517 |
517 |
|
if (!c) |
| 518 |
518 |
|
return; |
| 519 |
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 |
522 |
|
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ |
| 522 |
523 |
|
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); |
| 523 |
524 |
|
} else if (cme->message_type == netatom[NetActiveWindow]) { |
|
| 783 |
784 |
|
{ |
| 784 |
785 |
|
if (!c || !ISVISIBLE(c)) |
| 785 |
786 |
|
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); |
| 786 |
|
- |
/* was if (selmon->sel) */ |
| 787 |
787 |
|
if (selmon->sel && selmon->sel != c) |
| 788 |
788 |
|
unfocus(selmon->sel, 0); |
| 789 |
789 |
|
if (c) { |
|
| 804 |
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 */ |
| 808 |
808 |
|
void |
| 809 |
809 |
|
focusin(XEvent *e) |
| 810 |
810 |
|
{ |
|
| 823 |
823 |
|
return; |
| 824 |
824 |
|
if ((m = dirtomon(arg->i)) == selmon) |
| 825 |
825 |
|
return; |
| 826 |
|
- |
unfocus(selmon->sel, 0); /* s/1/0/ fixes input focus issues |
| 827 |
|
- |
in gedit and anjuta */ |
|
826 |
+ |
unfocus(selmon->sel, 0); |
| 828 |
827 |
|
selmon = m; |
| 829 |
828 |
|
focus(NULL); |
| 830 |
829 |
|
} |
|
| 961 |
960 |
|
if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) |
| 962 |
961 |
|
for (j = 0; j < LENGTH(modifiers); j++) |
| 963 |
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 |
1150 |
|
ocx = c->x; |
| 1152 |
1151 |
|
ocy = c->y; |
| 1153 |
1152 |
|
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
| 1154 |
|
- |
None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess) |
|
1153 |
+ |
None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess) |
| 1155 |
1154 |
|
return; |
| 1156 |
1155 |
|
if (!getrootptr(&x, &y)) |
| 1157 |
1156 |
|
return; |
|
| 1434 |
1433 |
|
long data[] = { state, None }; |
| 1435 |
1434 |
|
|
| 1436 |
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 |
|
|
| 1440 |
1439 |
|
int |
|
| 1516 |
1515 |
|
drawbar(selmon); |
| 1517 |
1516 |
|
} |
| 1518 |
1517 |
|
|
| 1519 |
|
- |
/* arg > 1.0 will set mfact absolutly */ |
|
1518 |
+ |
/* arg > 1.0 will set mfact absolutely */ |
| 1520 |
1519 |
|
void |
| 1521 |
1520 |
|
setmfact(const Arg *arg) |
| 1522 |
1521 |
|
{ |
|
| 1581 |
1580 |
|
/* supporting window for NetWMCheck */ |
| 1582 |
1581 |
|
wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); |
| 1583 |
1582 |
|
XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, |
| 1584 |
|
- |
PropModeReplace, (unsigned char *) &wmcheckwin, 1); |
|
1583 |
+ |
PropModeReplace, (unsigned char *) &wmcheckwin, 1); |
| 1585 |
1584 |
|
XChangeProperty(dpy, wmcheckwin, netatom[NetWMName], utf8string, 8, |
| 1586 |
|
- |
PropModeReplace, (unsigned char *) "dwm", 4); |
|
1585 |
+ |
PropModeReplace, (unsigned char *) "dwm", 4); |
| 1587 |
1586 |
|
XChangeProperty(dpy, root, netatom[NetWMCheck], XA_WINDOW, 32, |
| 1588 |
|
- |
PropModeReplace, (unsigned char *) &wmcheckwin, 1); |
|
1587 |
+ |
PropModeReplace, (unsigned char *) &wmcheckwin, 1); |
| 1589 |
1588 |
|
/* EWMH support per view */ |
| 1590 |
1589 |
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, |
| 1591 |
|
- |
PropModeReplace, (unsigned char *) netatom, NetLast); |
|
1590 |
+ |
PropModeReplace, (unsigned char *) netatom, NetLast); |
| 1592 |
1591 |
|
XDeleteProperty(dpy, root, netatom[NetClientList]); |
| 1593 |
|
- |
/* select for events */ |
|
1592 |
+ |
/* select events */ |
| 1594 |
1593 |
|
wa.cursor = cursor[CurNormal]->cursor; |
| 1595 |
|
- |
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask |
| 1596 |
|
- |
|EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; |
|
1594 |
+ |
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask |
|
1595 |
+ |
|ButtonPressMask|PointerMotionMask|EnterWindowMask |
|
1596 |
+ |
|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; |
| 1597 |
1597 |
|
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); |
| 1598 |
1598 |
|
XSelectInput(dpy, root, wa.event_mask); |
| 1599 |
1599 |
|
grabkeys(); |
|
| 1769 |
1769 |
|
Monitor *m = c->mon; |
| 1770 |
1770 |
|
XWindowChanges wc; |
| 1771 |
1771 |
|
|
| 1772 |
|
- |
/* The server grab construct avoids race conditions. */ |
| 1773 |
1772 |
|
detach(c); |
| 1774 |
1773 |
|
detachstack(c); |
| 1775 |
1774 |
|
if (!destroyed) { |
| 1776 |
1775 |
|
wc.border_width = c->oldbw; |
| 1777 |
|
- |
XGrabServer(dpy); |
|
1776 |
+ |
XGrabServer(dpy); /* avoid race conditions */ |
| 1778 |
1777 |
|
XSetErrorHandler(xerrordummy); |
| 1779 |
1778 |
|
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ |
| 1780 |
1779 |
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 1871 |
1870 |
|
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); |
| 1872 |
1871 |
|
XFree(info); |
| 1873 |
1872 |
|
nn = j; |
| 1874 |
|
- |
if (n <= nn) { |
| 1875 |
|
- |
for (i = 0; i < (nn - n); i++) { /* new monitors available */ |
|
1873 |
+ |
if (n <= nn) { /* new monitors available */ |
|
1874 |
+ |
for (i = 0; i < (nn - n); i++) { |
| 1876 |
1875 |
|
for (m = mons; m && m->next; m = m->next); |
| 1877 |
1876 |
|
if (m) |
| 1878 |
1877 |
|
m->next = createmon(); |
|
| 1881 |
1880 |
|
} |
| 1882 |
1881 |
|
for (i = 0, m = mons; i < nn && m; m = m->next, i++) |
| 1883 |
1882 |
|
if (i >= n |
| 1884 |
|
- |
|| (unique[i].x_org != m->mx || unique[i].y_org != m->my |
| 1885 |
|
- |
|| unique[i].width != m->mw || unique[i].height != m->mh)) |
|
1883 |
+ |
|| unique[i].x_org != m->mx || unique[i].y_org != m->my |
|
1884 |
+ |
|| unique[i].width != m->mw || unique[i].height != m->mh) |
| 1886 |
1885 |
|
{ |
| 1887 |
1886 |
|
dirty = 1; |
| 1888 |
1887 |
|
m->num = i; |
|
| 1892 |
1891 |
|
m->mh = m->wh = unique[i].height; |
| 1893 |
1892 |
|
updatebarpos(m); |
| 1894 |
1893 |
|
} |
| 1895 |
|
- |
} else { |
| 1896 |
|
- |
/* less monitors available nn < n */ |
|
1894 |
+ |
} else { /* less monitors available nn < n */ |
| 1897 |
1895 |
|
for (i = nn; i < n; i++) { |
| 1898 |
1896 |
|
for (m = mons; m && m->next; m = m->next); |
| 1899 |
|
- |
while (m->clients) { |
|
1897 |
+ |
while ((c = m->clients)) { |
| 1900 |
1898 |
|
dirty = 1; |
| 1901 |
|
- |
c = m->clients; |
| 1902 |
1899 |
|
m->clients = c->next; |
| 1903 |
1900 |
|
detachstack(c); |
| 1904 |
1901 |
|
c->mon = mons; |
|
| 1913 |
1910 |
|
free(unique); |
| 1914 |
1911 |
|
} else |
| 1915 |
1912 |
|
#endif /* XINERAMA */ |
| 1916 |
|
- |
/* default monitor setup */ |
| 1917 |
|
- |
{ |
|
1913 |
+ |
{ /* default monitor setup */ |
| 1918 |
1914 |
|
if (!mons) |
| 1919 |
1915 |
|
mons = createmon(); |
| 1920 |
1916 |
|
if (mons->mw != sw || mons->mh != sh) { |
|
| 1988 |
1984 |
|
} else |
| 1989 |
1985 |
|
c->maxa = c->mina = 0.0; |
| 1990 |
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 |
|
|
| 1994 |
1990 |
|
void |
|
| 2082 |
2078 |
|
} |
| 2083 |
2079 |
|
|
| 2084 |
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 |
| 2086 |
|
- |
* default error handler, which may call exit. */ |
|
2081 |
+ |
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs |
|
2082 |
+ |
* default error handler, which may call exit. */ |
| 2087 |
2083 |
|
int |
| 2088 |
2084 |
|
xerror(Display *dpy, XErrorEvent *ee) |
| 2089 |
2085 |
|
{ |
|
| 2098 |
2094 |
|
|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) |
| 2099 |
2095 |
|
return 0; |
| 2100 |
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 |
2098 |
|
return xerrorxlib(dpy, ee); /* may call exit */ |
| 2103 |
2099 |
|
} |
| 2104 |
2100 |
|
|