Fixes compilation on FreeBSD (and hopefully on other POSIX platforms)

This commit is contained in:
q3cpma 2017-11-30 16:53:55 +01:00
parent 6c69002ab4
commit fa3aab9768

View File

@ -21,6 +21,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <unistd.h>
#include <X11/Xatom.h>
@ -159,19 +160,27 @@ static void x11_set_window_class(Display *dpy, Window win)
static void x11_set_window_pid(Display *dpy, Window win)
{
long scret;
char *hostname;
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);
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));
}
errno = 0;
if((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno)
return;
if((hostname = malloc(scret + 1)) == NULL)
return;
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));
}
free(hostname);
}
void x11_set_window_attr(Display *dpy, Window win)