Using a queue ensures that events will be processed in order, i.e. if processing
an events generates new ones, those won't be handled before the first one is fully done.
We also let Qt process its own QEvents in between, in order to not block things like
network handling.