diff options
Diffstat (limited to '')
| -rw-r--r-- | README | 2 | ||||
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | dwm.1 | 14 | ||||
| -rw-r--r-- | dwm.c | 87 |
4 files changed, 31 insertions, 73 deletions
| @@ -40,7 +40,7 @@ like this in your .xinitrc: | |||
| 40 | 40 | ||
| 41 | while true | 41 | while true |
| 42 | do | 42 | do |
| 43 | echo `date` `uptime | sed 's/.*,//'` | 43 | xsetroot -name "`date` `uptime | sed 's/.*,//'`" |
| 44 | sleep 1 | 44 | sleep 1 |
| 45 | done | dwm | 45 | done | dwm |
| 46 | 46 | ||
diff --git a/config.def.h b/config.def.h index 7c19b2f..bb60471 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -12,7 +12,6 @@ static unsigned int borderpx = 1; /* border pixel of windows */ | |||
| 12 | static unsigned int snap = 32; /* snap pixel */ | 12 | static unsigned int snap = 32; /* snap pixel */ |
| 13 | static Bool showbar = True; /* False means no bar */ | 13 | static Bool showbar = True; /* False means no bar */ |
| 14 | static Bool topbar = True; /* False means bottom bar */ | 14 | static Bool topbar = True; /* False means bottom bar */ |
| 15 | static Bool readin = True; /* False means do not read stdin */ | ||
| 16 | static Bool usegrab = False; /* True means grabbing the X server | 15 | static Bool usegrab = False; /* True means grabbing the X server |
| 17 | during mouse-based resizals */ | 16 | during mouse-based resizals */ |
| 18 | 17 | ||
| @@ -20,13 +20,13 @@ Windows are grouped by tags. Each window can be tagged with one or multiple | |||
| 20 | tags. Selecting certain tags displays all windows with these tags. | 20 | tags. Selecting certain tags displays all windows with these tags. |
| 21 | .P | 21 | .P |
| 22 | dwm contains a small status bar which displays all available tags, the layout, | 22 | dwm contains a small status bar which displays all available tags, the layout, |
| 23 | the title of the focused window, and the text read from standard input. A | 23 | the title of the focused window, and the text read from the root window name |
| 24 | floating window is indicated with an empty square and a maximised | 24 | property. A floating window is indicated with an empty square and a maximised |
| 25 | floating window is indicated with a filled square before the windows | 25 | floating window is indicated with a filled square before the windows title. |
| 26 | title. The selected tags are indicated with a different color. The tags of | 26 | The selected tags are indicated with a different color. The tags of the focused |
| 27 | the focused window are indicated with a filled square in the top left | 27 | window are indicated with a filled square in the top left corner. The tags |
| 28 | corner. The tags which are applied to one or more windows are indicated | 28 | which are applied to one or more windows are indicated with an empty square in |
| 29 | with an empty square in the top left corner. | 29 | the top left corner. |
| 30 | .P | 30 | .P |
| 31 | dwm draws a small border around windows to indicate the focus state. | 31 | dwm draws a small border around windows to indicate the focus state. |
| 32 | .SH OPTIONS | 32 | .SH OPTIONS |
| @@ -6,12 +6,9 @@ | |||
| 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 | * Calls to fetch an X event from the event queue are blocking. Due reading | 9 | * The event handlers of dwm are organized in an array which is accessed |
| 10 | * status text from standard input, a select()-driven main loop has been | 10 | * whenever a new event has been fetched. This allows event dispatching |
| 11 | * implemented which selects for reads on the X connection and STDIN_FILENO to | 11 | * in O(1) time. |
| 12 | * handle all data smoothly. The event handlers of dwm are organized in an | ||
| 13 | * array which is accessed whenever a new event has been fetched. This allows | ||
| 14 | * event dispatching in O(1) time. | ||
| 15 | * | 12 | * |
| 16 | * 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 |
| 17 | * set the override_redirect flag. Clients are organized in a global | 14 | * set the override_redirect flag. Clients are organized in a global |
| @@ -30,7 +27,6 @@ | |||
| 30 | #include <stdlib.h> | 27 | #include <stdlib.h> |
| 31 | #include <string.h> | 28 | #include <string.h> |
| 32 | #include <unistd.h> | 29 | #include <unistd.h> |
| 33 | #include <sys/select.h> | ||
| 34 | #include <sys/types.h> | 30 | #include <sys/types.h> |
| 35 | #include <sys/wait.h> | 31 | #include <sys/wait.h> |
| 36 | #include <X11/cursorfont.h> | 32 | #include <X11/cursorfont.h> |
| @@ -196,6 +192,7 @@ static void updatebar(void); | |||
| 196 | static void updategeom(void); | 192 | static void updategeom(void); |
| 197 | static void updatenumlockmask(void); | 193 | static void updatenumlockmask(void); |
| 198 | static void updatesizehints(Client *c); | 194 | static void updatesizehints(Client *c); |
| 195 | static void updatestatus(void); | ||
| 199 | static void updatetitle(Client *c); | 196 | static void updatetitle(Client *c); |
| 200 | static void updatewmhints(Client *c); | 197 | static void updatewmhints(Client *c); |
| 201 | static void view(const Arg *arg); | 198 | static void view(const Arg *arg); |
| @@ -998,9 +995,11 @@ propertynotify(XEvent *e) { | |||
| 998 | Window trans; | 995 | Window trans; |
| 999 | XPropertyEvent *ev = &e->xproperty; | 996 | XPropertyEvent *ev = &e->xproperty; |
| 1000 | 997 | ||
| 1001 | if(ev->state == PropertyDelete) | 998 | if((ev->window == root) && (ev->atom = XA_WM_NAME)) |
| 999 | updatestatus(); | ||
| 1000 | else if(ev->state == PropertyDelete) | ||
| 1002 | return; /* ignore */ | 1001 | return; /* ignore */ |
| 1003 | if((c = getclient(ev->window))) { | 1002 | else if((c = getclient(ev->window))) { |
| 1004 | switch (ev->atom) { | 1003 | switch (ev->atom) { |
| 1005 | default: break; | 1004 | default: break; |
| 1006 | case XA_WM_TRANSIENT_FOR: | 1005 | case XA_WM_TRANSIENT_FOR: |
| @@ -1026,7 +1025,7 @@ propertynotify(XEvent *e) { | |||
| 1026 | 1025 | ||
| 1027 | void | 1026 | void |
| 1028 | quit(const Arg *arg) { | 1027 | quit(const Arg *arg) { |
| 1029 | readin = running = False; | 1028 | running = False; |
| 1030 | } | 1029 | } |
| 1031 | 1030 | ||
| 1032 | void | 1031 | void |
| @@ -1180,60 +1179,13 @@ restack(void) { | |||
| 1180 | 1179 | ||
| 1181 | void | 1180 | void |
| 1182 | run(void) { | 1181 | run(void) { |
| 1183 | char *p; | ||
| 1184 | char sbuf[sizeof stext]; | ||
| 1185 | fd_set rd; | ||
| 1186 | int r, xfd; | ||
| 1187 | unsigned int len, offset; | ||
| 1188 | XEvent ev; | 1182 | XEvent ev; |
| 1189 | 1183 | ||
| 1190 | /* main event loop, also reads status text from stdin */ | 1184 | /* main event loop */ |
| 1191 | XSync(dpy, False); | 1185 | XSync(dpy, False); |
| 1192 | xfd = ConnectionNumber(dpy); | 1186 | while(running && !XNextEvent(dpy, &ev)) { |
| 1193 | offset = 0; | 1187 | if(handler[ev.type]) |
| 1194 | len = sizeof stext - 1; | 1188 | (handler[ev.type])(&ev); /* call handler */ |
| 1195 | sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */ | ||
| 1196 | while(running) { | ||
| 1197 | FD_ZERO(&rd); | ||
| 1198 | if(readin) | ||
| 1199 | FD_SET(STDIN_FILENO, &rd); | ||
| 1200 | FD_SET(xfd, &rd); | ||
| 1201 | if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { | ||
| 1202 | if(errno == EINTR) | ||
| 1203 | continue; | ||
| 1204 | die("select failed\n"); | ||
| 1205 | } | ||
| 1206 | if(FD_ISSET(STDIN_FILENO, &rd)) { | ||
| 1207 | switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) { | ||
| 1208 | case -1: | ||
| 1209 | strncpy(stext, strerror(errno), len); | ||
| 1210 | readin = False; | ||
| 1211 | break; | ||
| 1212 | case 0: | ||
| 1213 | strncpy(stext, "EOF", 4); | ||
| 1214 | readin = False; | ||
| 1215 | break; | ||
| 1216 | default: | ||
| 1217 | for(p = sbuf + offset; r > 0; p++, r--, offset++) | ||
| 1218 | if(*p == '\n' || *p == '\0') { | ||
| 1219 | *p = '\0'; | ||
| 1220 | strncpy(stext, sbuf, len); | ||
| 1221 | p += r - 1; /* p is sbuf + offset + r - 1 */ | ||
| 1222 | for(r = 0; *(p - r) && *(p - r) != '\n'; r++); | ||
| 1223 | offset = r; | ||
| 1224 | if(r) | ||
| 1225 | memmove(sbuf, p - r + 1, r); | ||
| 1226 | break; | ||
| 1227 | } | ||
| 1228 | break; | ||
| 1229 | } | ||
| 1230 | drawbar(); | ||
| 1231 | } | ||
| 1232 | while(XPending(dpy)) { | ||
| 1233 | XNextEvent(dpy, &ev); | ||
| 1234 | if(handler[ev.type]) | ||
| 1235 | (handler[ev.type])(&ev); /* call handler */ | ||
| 1236 | } | ||
| 1237 | } | 1189 | } |
| 1238 | } | 1190 | } |
| 1239 | 1191 | ||
| @@ -1356,8 +1308,7 @@ setup(void) { | |||
| 1356 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | 1308 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); |
| 1357 | XDefineCursor(dpy, barwin, cursor[CurNormal]); | 1309 | XDefineCursor(dpy, barwin, cursor[CurNormal]); |
| 1358 | XMapRaised(dpy, barwin); | 1310 | XMapRaised(dpy, barwin); |
| 1359 | strcpy(stext, "dwm-"VERSION); | 1311 | updatestatus(); |
| 1360 | drawbar(); | ||
| 1361 | 1312 | ||
| 1362 | /* EWMH support per view */ | 1313 | /* EWMH support per view */ |
| 1363 | XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, | 1314 | XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, |
| @@ -1365,7 +1316,8 @@ setup(void) { | |||
| 1365 | 1316 | ||
| 1366 | /* select for events */ | 1317 | /* select for events */ |
| 1367 | wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask | 1318 | wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask |
| 1368 | |EnterWindowMask|LeaveWindowMask|StructureNotifyMask; | 1319 | |EnterWindowMask|LeaveWindowMask|StructureNotifyMask |
| 1320 | |PropertyChangeMask; | ||
| 1369 | XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); | 1321 | XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); |
| 1370 | XSelectInput(dpy, root, wa.event_mask); | 1322 | XSelectInput(dpy, root, wa.event_mask); |
| 1371 | 1323 | ||
| @@ -1647,6 +1599,13 @@ updatetitle(Client *c) { | |||
| 1647 | } | 1599 | } |
| 1648 | 1600 | ||
| 1649 | void | 1601 | void |
| 1602 | updatestatus() { | ||
| 1603 | if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) | ||
| 1604 | strcpy(stext, "dwm-"VERSION); | ||
| 1605 | drawbar(); | ||
| 1606 | } | ||
| 1607 | |||
| 1608 | void | ||
| 1650 | updatewmhints(Client *c) { | 1609 | updatewmhints(Client *c) { |
| 1651 | XWMHints *wmh; | 1610 | XWMHints *wmh; |
| 1652 | 1611 | ||
