Extract event processing out of event_loop()
Extract event processing out of event_loop()

To avoid too many levels of nested blocks, move the event handling logic
in a separate function.

Genymobile/scrcpy,Genymobile/scrcpy,Genymobile/scrcpy