Fix T43652: X11 "_NET_WM_PID" not set by Ghost

D1107 by @kevindietrich
This commit is contained in:
Campbell Barton 2015-02-19 09:19:12 +11:00
parent f0527d9631
commit 5ed2cc8070
Notes: blender-bot 2023-02-14 09:29:42 +01:00
Referenced by issue #43652, X11 property "_NET_WM_PID" is not set by Blender
1 changed files with 30 additions and 0 deletions

View File

@ -56,6 +56,9 @@
#include <cstring>
#include <cstdio>
/* gethostname */
#include <unistd.h>
#include <algorithm>
#include <string>
@ -71,6 +74,9 @@ typedef struct {
#define MWM_HINTS_DECORATIONS (1L << 1)
#ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 64
#endif
// #define GHOST_X11_GRAB
@ -504,6 +510,30 @@ GHOST_WindowX11(
BLENDER_ICON_48x48x32[0] * BLENDER_ICON_48x48x32[1] + 2);
}
/* set the process ID (_NET_WM_PID) */
{
Atom _NET_WM_PID = XInternAtom(m_display, "_NET_WM_PID", False);
pid_t pid = getpid();
XChangeProperty(m_display, m_window, _NET_WM_PID, XA_CARDINAL,
32, PropModeReplace, (unsigned char *)&pid, 1);
}
/* set the hostname (WM_CLIENT_MACHINE) */
{
char hostname[HOST_NAME_MAX];
char *text_array[1];
XTextProperty text_prop;
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
text_array[0] = hostname;
XStringListToTextProperty(text_array, 1, &text_prop);
XSetWMClientMachine(m_display, m_window, &text_prop);
XFree(text_prop.value);
}
#ifdef WITH_X11_XINPUT
initXInputDevices();