static VkResult x11_acquire_next_image_poll_x11(struct x11_swapchain *chain, uint32_t *image_index, uint64_t timeout) { xcb_generic_event_t *event; struct pollfd pfds; uint64_t atimeout; while (1) { for (uint32_t i = 0; i < chain->image_count; i++) { if (!chain->images[i].busy) { /* We found a non-busy image */ xshmfence_await(chain->images[i].shm_fence); *image_index = i; chain->images[i].busy = true; return VK_SUCCESS; } } xcb_flush(chain->conn); if (timeout == UINT64_MAX) { event = xcb_wait_for_special_event(chain->conn, chain->special_event); if (!event) return VK_ERROR_OUT_OF_DATE_KHR; } else { event = xcb_poll_for_special_event(chain->conn, chain->special_event); if (!event) { int ret; if (timeout == 0) return VK_NOT_READY; atimeout = wsi_get_absolute_timeout(timeout); pfds.fd = xcb_get_file_descriptor(chain->conn); pfds.events = POLLIN; ret = poll(&pfds, 1, timeout / 1000 / 1000); if (ret == 0) return VK_TIMEOUT; if (ret == -1) return VK_ERROR_OUT_OF_DATE_KHR; /* If a non-special event happens, the fd will still * poll. So recalculate the timeout now just in case. */ uint64_t current_time = wsi_get_current_time(); if (atimeout > current_time) timeout = atimeout - current_time; else timeout = 0; continue; } } VkResult result = x11_handle_dri3_present_event(chain, (void *)event); free(event); if (result != VK_SUCCESS) return result; } }
static void dri3_flush_present_events(struct vl_dri3_screen *scrn) { if (scrn->special_event) { xcb_generic_event_t *ev; while ((ev = xcb_poll_for_special_event( scrn->conn, scrn->special_event)) != NULL) dri3_handle_present_event(scrn, (xcb_present_generic_event_t *)ev); } }
static void PRESENTflush_events(PRESENTpriv *present_priv, BOOL assert_no_other_thread_waiting) { xcb_generic_event_t *ev; if ((present_priv->xcb_wait && !assert_no_other_thread_waiting) || /* don't steal events to someone waiting */ !present_priv->special_event) return; while ((ev = xcb_poll_for_special_event(present_priv->xcb_connection, present_priv->special_event)) != NULL) { PRESENThandle_events(present_priv, (void *) ev); } }
/** dri3_flush_present_events * * Process any present events that have been received from the X server */ static void dri3_flush_present_events(struct loader_dri3_drawable *draw) { /* Check to see if any configuration changes have occurred * since we were last invoked */ if (draw->special_event) { xcb_generic_event_t *ev; while ((ev = xcb_poll_for_special_event(draw->conn, draw->special_event)) != NULL) { xcb_present_generic_event_t *ge = (void *) ev; dri3_handle_present_event(draw, ge); } } }
virtual shared_generic_event_ptr poll_for_special_event(xcb_special_event_t * se) const { return shared_generic_event_ptr(xcb_poll_for_special_event(m_c.get(), se)); }