[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Sun, 10 Apr 2011 17:19:04 +0000 (UTC)

changeset: 719:7f6625c57719
tag: tip
user: Moritz Wilhelmy <moritz+hg_AT_wzff.de>
date: Sun Apr 10 19:20:21 2011 +0200
files: dwm.suckless.org/patches/dwm-r1533-stdin.diff dwm.suckless.org/patches/stdin.md
description:
added stdin.md and stdin.diff


diff -r e1e6436a5b6d -r 7f6625c57719 dwm.suckless.org/patches/dwm-r1533-stdin.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/dwm-r1533-stdin.diff Sun Apr 10 19:20:21 2011 +0200
_AT_@ -0,0 +1,134 @@
+This backports pre-dwm-5.3 behaviour where the status bar content was read from
+stdin instead of the root window title. I did this, because I had several
+problems with the "new" method, on different machines, with different
+configurations, including vanilla, where the statusbar froze.
+It adds some LOC, but is not broken for me.
+
+diff -r ba7d976f74d3 config.def.h
+--- a/config.def.h Fri Mar 25 14:06:46 2011 +0000
++++ b/config.def.h Sun Apr 10 19:07:26 2011 +0200
+_AT_@ -12,6 +12,7 @@
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+ static const Bool topbar = True; /* False means bottom bar */
++static Bool readin = True; /* False means do not read stdin */
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+diff -r ba7d976f74d3 dwm.c
+--- a/dwm.c Fri Mar 25 14:06:46 2011 +0000
++++ b/dwm.c Sun Apr 10 19:07:26 2011 +0200
+_AT_@ -28,6 +28,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <sys/select.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ #include <X11/cursorfont.h>
+_AT_@ -232,7 +233,6 @@
+ static void updatebars(void);
+ static void updatenumlockmask(void);
+ static void updatesizehints(Client *c);
+-static void updatestatus(void);
+ static void updatetitle(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
+_AT_@ -1251,9 +1251,7 @@
+ Window trans;
+ XPropertyEvent *ev = &e->xproperty;
+
+- if((ev->window == root) && (ev->atom == XA_WM_NAME))
+- updatestatus();
+- else if(ev->state == PropertyDelete)
++ if(ev->state == PropertyDelete)
+ return; /* ignore */
+ else if((c = wintoclient(ev->window))) {
+ switch (ev->atom) {
+_AT_@ -1413,12 +1411,60 @@
+
+ void
+ run(void) {
++ char *p;
++ char sbuf[sizeof stext];
++ fd_set rd;
++ int r, xfd;
++ unsigned int len, offset;
+ XEvent ev;
+- /* main event loop */
++
++ /* main event loop, also reads status text from stdin */
+ XSync(dpy, False);
+- while(running && !XNextEvent(dpy, &ev)) {
+- if(handler[ev.type])
+- handler[ev.type](&ev); /* call handler */
++ xfd = ConnectionNumber(dpy);
++ offset = 0;
++ len = sizeof stext - 1;
++ sbuf[len] = stext[len] = '\0'; /* 0-terminator is never touched */
++ while(running) {
++ FD_ZERO(&rd);
++ if(readin)
++ FD_SET(STDIN_FILENO, &rd);
++ FD_SET(xfd, &rd);
++ if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
++ if(errno == EINTR)
++ continue;
++ die("select failed\n");
++ }
++ if(FD_ISSET(STDIN_FILENO, &rd)) {
++ switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) {
++ case -1:
++ strncpy(stext, strerror(errno), len);
++ readin = False;
++ break;
++ case 0:
++ strncpy(stext, "EOF", 4);
++ readin = False;
++ break;
++ default:
++ for(p = sbuf + offset; r > 0; p++, r--, offset++)
++ if(*p == '\n' || *p == '\0') {
++ *p = '\0';
++ strncpy(stext, sbuf, len);
++ p += r - 1; /* p is sbuf + offset + r - 1 */
++ for(r = 0; *(p - r) && *(p - r) != '\n'; r++);
++ offset = r;
++ if(r)
++ memmove(sbuf, p - r + 1, r);
++ break;
++ }
++ break;
++ }
++ drawbars();
++ }
++ while(XPending(dpy)) {
++ XNextEvent(dpy, &ev);
++ if(handler[ev.type])
++ (handler[ev.type])(&ev); /* call handler */
++ }
+ }
+ }
+
+_AT_@ -1539,7 +1585,6 @@
+ XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ /* init bars */
+ updatebars();
+- updatestatus();
+ /* EWMH support per view */
+ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) netatom, NetLast);
+_AT_@ -1916,13 +1961,6 @@
+ }
+
+ void
+-updatestatus(void) {
+- if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+- strcpy(stext, "dwm-"VERSION);
+- drawbar(selmon);
+-}
+-
+-void
+ updatewmhints(Client *c) {
+ XWMHints *wmh;
+
diff -r e1e6436a5b6d -r 7f6625c57719 dwm.suckless.org/patches/stdin.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/stdin.md Sun Apr 10 19:20:21 2011 +0200
_AT_@ -0,0 +1,22 @@
+STDIN
+=====
+
+Description
+-----------
+
+This backports dwm's old behaviour found in pre-5.3 releases to read the status
+text from stdin. It's a matter of personal preference, adds a few LOC, is less
+prone to freezing (in my experience) and included here for the sake of
+completeness.
+
+Download
+--------
+
+* [dwm-r1533-stdin.diff](dwm-r1533-stdin.diff)
+
+Author
+------
+
+This was originally part of dwm-5.2 and written by Anselm R. Garbe,
+but the one to blame for the backport is Moritz Wilhelmy, who can be reached by
+writing a mail to moritz plus dwm at wzff dot de.
Received on Sun Apr 10 2011 - 19:19:04 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:42 CEST