This commit is contained in:
Kovid Goyal 2024-04-15 16:07:38 +05:30
parent 4ad8d30751
commit 5b587060a4
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

18
glfw/wl_init.c vendored
View file

@ -633,10 +633,9 @@ GLFWAPI GLFWColorScheme glfwGetCurrentSystemColorTheme(void) {
return glfw_current_system_color_theme();
}
GLFWAPI pid_t glfwWaylandCompositorPID(void) {
if (!_glfw.wl.display) return -1;
int fd = wl_display_get_fd(_glfw.wl.display);
if (fd < 0) return -1;
#ifdef __linux__
static pid_t
get_socket_peer_pid(int fd) {
struct ucred ucred;
socklen_t len = sizeof(struct ucred);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) {
@ -645,6 +644,17 @@ GLFWAPI pid_t glfwWaylandCompositorPID(void) {
}
return ucred.pid;
}
#else
static pid_t
get_socket_peer_pid(int fd) { return -1; }
#endif
GLFWAPI pid_t glfwWaylandCompositorPID(void) {
if (!_glfw.wl.display) return -1;
int fd = wl_display_get_fd(_glfw.wl.display);
if (fd < 0) return -1;
return get_socket_peer_pid(fd);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////