From d8ec6f91a9857fb651f39de7929f17543d1c996c Mon Sep 17 00:00:00 2001 From: eylles Date: Sat, 11 Sep 2021 08:14:34 -0600 Subject: Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties (#13) Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties Co-authored-by: Leon Kowarschick Co-authored-by: Kian Kasad Co-authored-by: NRK --- window.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index 439062c..ded20c8 100644 --- a/window.c +++ b/window.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,7 @@ void win_init(win_t *win) INIT_ATOM_(_NET_WM_ICON_NAME); INIT_ATOM_(_NET_WM_ICON); INIT_ATOM_(_NET_WM_STATE); + INIT_ATOM_(_NET_WM_PID); INIT_ATOM_(_NET_WM_STATE_FULLSCREEN); } @@ -168,6 +170,8 @@ void win_open(win_t *win) int gmask; XSizeHints sizehints; XWMHints hints; + pid_t pid; + char hostname[255]; e = &win->env; parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); @@ -215,6 +219,22 @@ void win_open(win_t *win) if (win->xwin == None) error(EXIT_FAILURE, 0, "Error creating X window"); + /* set the _NET_WM_PID */ + pid = getpid(); + XChangeProperty(e->dpy, win->xwin, + atoms[ATOM__NET_WM_PID], XA_CARDINAL, sizeof(pid_t) * 8, + PropModeReplace, (unsigned char *) &pid, 1); + + /* set the _NET_WM_PID */ + if (gethostname(hostname, sizeof(hostname)) == 0) { + XTextProperty tp; + tp.value = (unsigned char *)hostname; + tp.nitems = strnlen(hostname, sizeof(hostname)); + tp.encoding = XA_STRING; + tp.format = 8; + XSetWMClientMachine(e->dpy, win->xwin, &tp); + } + XSelectInput(e->dpy, win->xwin, ButtonReleaseMask | ButtonPressMask | KeyPressMask | PointerMotionMask | StructureNotifyMask); -- cgit v1.2.3-54-g00ecf