[dev] [PATCH] Sets _NET_WM_PID on startup

From: Benjamin R. Haskell <suckless_AT_benizi.com>
Date: Mon, 21 Oct 2013 12:33:40 -0400

This sets _NET_WM_PID on startup. Not sure if any error handling's needed. I
used this for quite a while before I switched back to urxvt (for scrollback)
for the same purpose as the recent "in $PWD" thread.

---
 st.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/st.c b/st.c
index 50b58a7..e3a7719 100644
--- a/st.c
+++ b/st.c
_AT_@ -399,6 +399,7 @@ static int xsetcolorname(int, const char *);
 static int xloadfont(Font *, FcPattern *);
 static void xloadfonts(char *, int);
 static int xloadfontset(Font *);
+static void xsetnetwmpid(void);
 static void xsettitle(char *);
 static void xresettitle(void);
 static void xsetpointermotion(int);
_AT_@ -3028,6 +3029,7 @@ xinit(void) {
 	xresettitle();
 	XMapWindow(xw.dpy, xw.win);
 	xhints();
+	xsetnetwmpid();
 	XSync(xw.dpy, 0);
 }
 
_AT_@ -3347,6 +3349,13 @@ xdrawcursor(void) {
 	}
 }
 
+void
+xsetnetwmpid(void) {
+	Atom _NET_WM_PID = XInternAtom(xw.dpy, "_NET_WM_PID", False);
+	pid_t pid = getpid();
+	XChangeProperty(xw.dpy, xw.win, _NET_WM_PID, XA_CARDINAL, 32,
+			PropModeReplace, (unsigned char *)&pid, 1);
+}
 
 void
 xsettitle(char *p) {
-- 
1.8.4.1
Received on Mon Oct 21 2013 - 18:33:40 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 21 2013 - 18:36:06 CEST