Instead of "polling" to see if a quit timer has expired, start a single
timer that expires after the confiugred delay when no more surfaces are
open. That timer can be cancelled if necessary.
Changes:
- Add WindowsPty, which uses the ConPTY API to create a pseudo console
- Pty now selects between PosixPty and WindowsPty
- Windows support in Command, including the ability to launch a process with a pseudo console
- Enable Command tests on windows
- Add some environment variable abstractions to handle the missing libc APIs on Windows
- Windows version of ReadThread
The surface runs on the same thread as the app so if we use the app
mailbox then we risk filling the queue before it can drain. The surface
should use the app directly.
This commit just changes all the calls to use the app directly. We may
also want to coalesce certain changes to avoid too much CPU but I defer
that to a future change.
We previously never set the focused pointer to null. I thought this
would be fine because a `hasSurface` check would say it doesn't exist.
But I didn't account for the fact that a deleted surface followed very
quickly by a new surface would free the pointer, then the allocation
would reuse the very same pointer, making `hasSurface` return a false
positive.
Well, technically, hasSurface is not wrong, the surface exists, but its
not really the same surface, its just a surface that happens to have the
same pointer as a previously freed surface.
Co-authored-by: Will Pragnell <wpragnell@gmail.com>
Fontconfig in particular appears unsafe to initialize multiple times.
Font discovery is a singleton object in an application and only ever
accessed from the main thread so we can work around this by only
initializing and caching the font discovery mechanism exactly once on
the app singleton.