From 18b2bd527c27a6fb2cea0f883983d3e04aff4b02 Mon Sep 17 00:00:00 2001 From: q3cpma Date: Thu, 23 Nov 2017 19:15:59 +0100 Subject: [PATCH] Set _NET_WM_PID Also set WM_CLIENT_MACHINE since https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html says you must do so if setting the first. --- gfx/common/x11_common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index a9d2fcb334..20eebf8da3 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -21,6 +21,8 @@ #include #include +#include + #include #ifdef HAVE_CONFIG_H @@ -155,9 +157,27 @@ static void x11_set_window_class(Display *dpy, Window win) XSetClassHint(dpy, win, &hint); } +static void x11_set_window_pid(Display *dpy, Window win) +{ + pid_t pid = getpid(); + char hostname[HOST_NAME_MAX + 1]; + + XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_PID", False), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + + if(gethostname(hostname, HOST_NAME_MAX + 1) == -1) + RARCH_WARN("Failed to get hostname.\n"); + else + { + XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, + PropModeReplace, (unsigned char *)hostname, strlen(hostname)); + } +} + void x11_set_window_attr(Display *dpy, Window win) { x11_set_window_class(dpy, win); + x11_set_window_pid(dpy, win); } static void xdg_screensaver_inhibit(Window wnd)