nsxivd8ec6f9
Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties (#13)
Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties
+21 −0
2 files changed
| @@ -385,6 +385,7 @@ enum { | |||
| 385 | 385 | ATOM__NET_WM_ICON_NAME, | |
| 386 | 386 | ATOM__NET_WM_ICON, | |
| 387 | 387 | ATOM__NET_WM_STATE, | |
| 388 | + | ATOM__NET_WM_PID, | |
| 388 | 389 | ATOM__NET_WM_STATE_FULLSCREEN, | |
| 389 | 390 | ATOM_COUNT | |
| 390 | 391 | }; | |
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | #include <stdlib.h> | |
| 26 | 26 | #include <string.h> | |
| 27 | 27 | #include <locale.h> | |
| 28 | + | #include <unistd.h> | |
| 28 | 29 | #include <X11/cursorfont.h> | |
| 29 | 30 | #include <X11/Xatom.h> | |
| 30 | 31 | #include <X11/Xresource.h> | |
| @@ -151,6 +152,7 @@ void win_init(win_t *win) | |||
| 151 | 152 | INIT_ATOM_(_NET_WM_ICON_NAME); | |
| 152 | 153 | INIT_ATOM_(_NET_WM_ICON); | |
| 153 | 154 | INIT_ATOM_(_NET_WM_STATE); | |
| 155 | + | INIT_ATOM_(_NET_WM_PID); | |
| 154 | 156 | INIT_ATOM_(_NET_WM_STATE_FULLSCREEN); | |
| 155 | 157 | } | |
| 156 | 158 | ||
| @@ -168,6 +170,8 @@ void win_open(win_t *win) | |||
| 168 | 170 | int gmask; | |
| 169 | 171 | XSizeHints sizehints; | |
| 170 | 172 | XWMHints hints; | |
| 173 | + | pid_t pid; | |
| 174 | + | char hostname[255]; | |
| 171 | 175 | ||
| 172 | 176 | e = &win->env; | |
| 173 | 177 | parent = options->embed != 0 ? options->embed : RootWindow(e->dpy, e->scr); | |
| @@ -215,6 +219,22 @@ void win_open(win_t *win) | |||
| 215 | 219 | if (win->xwin == None) | |
| 216 | 220 | error(EXIT_FAILURE, 0, "Error creating X window"); | |
| 217 | 221 | ||
| 222 | + | /* set the _NET_WM_PID */ | |
| 223 | + | pid = getpid(); | |
| 224 | + | XChangeProperty(e->dpy, win->xwin, | |
| 225 | + | atoms[ATOM__NET_WM_PID], XA_CARDINAL, sizeof(pid_t) * 8, | |
| 226 | + | PropModeReplace, (unsigned char *) &pid, 1); | |
| 227 | + | ||
| 228 | + | /* set the _NET_WM_PID */ | |
| 229 | + | if (gethostname(hostname, sizeof(hostname)) == 0) { | |
| 230 | + | XTextProperty tp; | |
| 231 | + | tp.value = (unsigned char *)hostname; | |
| 232 | + | tp.nitems = strnlen(hostname, sizeof(hostname)); | |
| 233 | + | tp.encoding = XA_STRING; | |
| 234 | + | tp.format = 8; | |
| 235 | + | XSetWMClientMachine(e->dpy, win->xwin, &tp); | |
| 236 | + | } | |
| 237 | + | ||
| 218 | 238 | XSelectInput(e->dpy, win->xwin, | |
| 219 | 239 | ButtonReleaseMask | ButtonPressMask | KeyPressMask | | |
| 220 | 240 | PointerMotionMask | StructureNotifyMask); | |