We can't start sending events from the thread before the QApplication
is properly initialized.
So add a state in the state machine and wait until the event loop is initialized
to send the first event.
This is part of #204 and has the additional benefit that at least on macOS
the icon in the dock doesn't appear out of a sudden but only when the user
explicitly requested a preview.
* Provide an internal behavior parameter to run_event_loop() that we can use
from the preview to not quit when the last window was closed.
* Fix Drop for the winit event loop GraphicsWindow to drop the backend window correctly
when unmapping, not when the graphics window dies. Otherwise QuitOnLastWindowClosed doesn't work.
This way we can serve preview requests immediately.
This basically makes post_event safe to call before the event loop is entered.
The events will be queued up and sent when the event loop
is created and we have access
to the proxy, which will take over the queue.
Run the preview in the main thread, as required for winit, and run the LSP
main loop in a secondary thread.
At least three more follow-up changes are needed, but this gets the
preview showing for example on macOS.