mirror of
https://github.com/yshui/picom.git
synced 2025-04-21 18:03:02 -04:00
picom: get max hostname length with sysconf()
For FreeBSD compatibility, which doesn't define HOST_NAME_MAX. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
02daff8bc8
commit
27d59dbb30
1 changed files with 7 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <xcb/composite.h>
|
||||
#include <xcb/damage.h>
|
||||
#include <xcb/glx.h>
|
||||
|
@ -972,8 +973,10 @@ static int register_cm(session_t *ps) {
|
|||
// Set WM_CLIENT_MACHINE. As per EWMH, because we set _NET_WM_PID, we must also
|
||||
// set WM_CLIENT_MACHINE.
|
||||
{
|
||||
char hostname[HOST_NAME_MAX];
|
||||
if (gethostname(hostname, sizeof(hostname)) == 0) {
|
||||
const auto hostname_max = (unsigned long)sysconf(_SC_HOST_NAME_MAX);
|
||||
char *hostname = malloc(hostname_max);
|
||||
|
||||
if (gethostname(hostname, hostname_max) == 0) {
|
||||
e = xcb_request_check(
|
||||
ps->c, xcb_change_property_checked(
|
||||
ps->c, XCB_PROP_MODE_REPLACE, ps->reg_win,
|
||||
|
@ -987,6 +990,8 @@ static int register_cm(session_t *ps) {
|
|||
} else {
|
||||
log_error_errno("Failed to get hostname");
|
||||
}
|
||||
|
||||
free(hostname);
|
||||
}
|
||||
|
||||
// Set _NET_WM_PID
|
||||
|
|
Loading…
Add table
Reference in a new issue