Make waitForNativeEvent able to be async.

We still don’t fill in the native event structure properly, but now we
only get an invalid event once every 10 seconds instead of in a tight
loop.