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)