Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)
* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
Previously we pretty much hardcoded most of the globals we requested,
causing compatibility issues with certain compositors like Weston, which
support only some pretty old versions or miss some more advanced
protocols.
To put fuel on the fire, we also errored out when certain protocols
weren't available, despite us being able to boot a game just fine (but
obviously with a degraded featureset).
The solution is to simply allow all the way from version 1 to the
current latest, adding some compatibility code (such as for older
`wl_output`s or newer `wl_pointer`s).
While we're at it, this commit also fixes a few typos and naming inconsistencies
I found.
The OS module get_unique_id and get_processor_name rely
on linux files which don't exist on a standard FreeBSD install,
make sysctl calls to get the required data.
Before, the cursor kept updating for no good reason really.
It's also a bit neater and it ever-so-slightly makes `WAYLAND_DEBUG`
logs easier to read, although they're still spammed by the window's
frame logic (which is needed).
- `Main::setup` early exits (failure or `--help`/`--version`) now
consistently return `EXIT_FAILURE` or `EXIT_SUCCESS` on all platforms,
instead of 255 on some and a Godot Error code on others.
- `Main::start` now returns the exit code, simplifying the handling of early
failures.
- `Main::iteration` needs to explicit set the exit code in OS if it errors
out.
- Web and iOS now properly return `OS::get_exit_code()` instead of 0.
This code was already partially there, although heavily incomplete and
nowadays commented out.
It got broken after the `WaylandThread` refactor and I didn't bother to
bring it over, preferring to `#if 0` it into oblivion for the time
being as I don't have a tablet/pen which support an eraser and tilt
reporting.
This commit brings it back and adds proper multi-tool support (needed
for eraser detection) thanks to winston-yallow, who could test this code
with their more capable tablet.
This is a pretty popular approach that took a while for me to wrap my
head around and which only recently got "official" support through an
update (xdg_shell version 6), so I think that this is all-in-all a
better option than the overkill 2000Hz ticking we have now :P
Basically, we wait for a frame event and, if either too much time passes
or we get the new `suspended` state, we consider the window as "hidden"
and stop drawing, ticking by the low usage rate.
This should work great for KDE and Mutter, which support the new state,
but not yet for sway, which is still stuck at a very old xdg_shell
version and thus falls back to the timeout approach.
Be aware that if we rely on timing out the engine will have to stall for
the whole timeout, which _could_ be problematic but doensn't seem like
it. Further testing is needed.
Special thanks go to the guys over at #wayland on OFTC, who very
patiently explained me this approach way too many times.