This commit is contained in:
Kovid Goyal
2024-04-15 16:07:38 +05:30
parent 4ad8d30751
commit 5b587060a4

18
glfw/wl_init.c vendored
View File

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