xcb_wait_for_special_event is a trap because Present doesn't have in-band window destroy notifies, so if you wait on a special event for a window whose deletion you just missed, no event will ever arrive. To avoid it, we start by noticing that the IMMEDIATE-mode ANI path is already very close to avoiding
wait_for, so we port it to use
xcb_poll_for_special_event and careful
poll() timeouts. Having done that, we observe the symmetry between that and the bottom of the FIFO queue management loop: both want to run the event loop for an arbitrary amount of time until something maybe happens. So we split the "run the event queue" code into common code with a caller-specified predicate for ending the loop, and port the fifo queue management to that.
This should fix #6685, I think, hence tagging this with zink and GLX. In that issue we are stalling in the
wait_for in the FIFO manager thread during context teardown. With this change,
x11_swapchain_destroy will mark the swapchain dead, and (eventually) the queue thread will notice that and terminate.