Hello, misc; I've been attempting to use OpenBSD libxcb to find the process ID of a window. The function used to retrieve the PID is as follows:
pid_t winpid(Window w) { pid_t result = 0; xcb_res_client_id_spec_t spec = {0}; spec.client = w; spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID; xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec); xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, NULL); if (!r) return (pid_t)0; xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r); for (; i.rem; xcb_res_client_id_value_next(&i)) { spec = i.data->spec; if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) { uint32_t *t = xcb_res_client_id_value_value(i.data); result = *t; break; } } free(r); if (result == (pid_t)-1) result = 0; return result; } The code compiles, however the function returns 0 as a result. I've checked the value of i.rem; it's always 0. I've made sure that the XCB connection (represented by xcon) exists. Has anyone else encountered this error? Thank you in advance. Ben Raskin.