loader/dri3: Check for window destruction in dri3_wait_for_event_locked
If the underlying X11 window gets destroyed, the event we're waiting for may never be delivered, in which case xcb_wait_for_special_event would hang indefinitely.
Solution:
- Use xcb_poll_for_special_event to check if an event has arrived yet.
- If not, Wait up to ~1s for XCB's file descriptor to become readable; if it does, go back to step 1.
- If the file descriptor didn't become readable, make a round-trip to the X server to check that the window still exists. Go back to step 1 if it does, otherwise bail.
Also add an early bail-out when it's known that the window was destroyed.
Closes: #116 (closed)