However, based on this comment in w32_read_socket, I think we can't use the x_wait_for_event approach for w32. /* Check which frames are still visible, if we have enqueued any user events or been notified of events that may affect visibility. We do this here because there doesn't seem to be any direct notification from Windows that the visibility of a window has changed (at least, not in all cases). */ The final patch uses the same timeout variable, not sure if that's much of an improvement.