diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-08-31 20:23:51 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-08-31 20:23:51 +0200 |
commit | 908e03de1ac31dae335c3d8f3c7baacc3788a745 (patch) | |
tree | c4b3a13978e8ffb50c8077e17e0d1a1eb717de9a /src/winwidget.c | |
parent | f940401bbcf0af43adbf28748a717edd651bbe22 (diff) | |
parent | 96f5db936b65560333fed8eaee74c2e19b2c2e12 (diff) |
Merge branch 'zeising-master'
Diffstat (limited to 'src/winwidget.c')
-rw-r--r-- | src/winwidget.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/winwidget.c b/src/winwidget.c index 9495c7f..758183b 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -153,7 +153,12 @@ void winwidget_create_window(winwidget ret, int w, int h) int x = 0; int y = 0; char *tmpname; +#ifdef HOST_NAME_MAX char hostname[HOST_NAME_MAX]; +#else /* ! HOST_NAME_MAX */ + long host_name_max; + char *hostname; +#endif /* HOST_NAME_MAX */ D(("winwidget_create_window %dx%d\n", w, h)); @@ -278,12 +283,25 @@ void winwidget_create_window(winwidget ret, int w, int h) XChangeProperty(disp, ret->win, prop, XA_CARDINAL, sizeof(pid_t) * 8, PropModeReplace, (const unsigned char *)&pid, 1); +#ifdef HOST_NAME_MAX if (gethostname(hostname, HOST_NAME_MAX) == 0) { hostname[HOST_NAME_MAX-1] = '\0'; prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False); XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8, PropModeReplace, (unsigned char *)hostname, strlen(hostname)); } +#else /* ! HOST_NAME_MAX */ + if ((host_name_max = sysconf(_SC_HOST_NAME_MAX)) != -1 ) { + if ((hostname = calloc(1, host_name_max + 1)) != NULL ) { + if (gethostname(hostname, host_name_max) == 0) { + prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False); + XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8, + PropModeReplace, (unsigned char *)hostname, strlen(hostname)); + } + free(hostname); + } + } +#endif /* HOST_NAME_MAX */ XSetWMProtocols(disp, ret->win, &wmDeleteWindow, 1); winwidget_update_title(ret); |