refactor request handlers
The request handler procs (especially in the extensions) are pretty complex beasts, which really deserve more care.
One the one hand, we have two procs for each request (as well the dispatches), one for the byte-swapping and one for the actual request handling. But we also have ugly cases (eg. xf86vidmode extension) having a lot of version-specific request (different payload structs depending on the client's currently selected protocol version).
Core protocol requests pose their own challenges, because they're sometimes hijacked by extensions (eg. Panoramix redirecting a bunch of requests to it's own implementation, for mirroring mirroring screen operations onto all individual screens, with changed geometry), in at least one case (amdgpu) even by drivers. Therefore leaving core requests out of scope for now.
Since there's still a lot of technical debt in here, the refactoring goes in several phases:
- reduce complexity in request handlers and align all of them to a very simple scheme, as already found in most them:
- a dispatch function: switch statement calling the individual (sub-)request handlers
- a similar dispatch function for the byte-swapped case - calling byte-swapping handlers, which then calling the actual request handlers
- all following the same layout (eg. using REQUEST() macro for declaring stuff* pointer, sending the reply at the end of the function, ...)
- add/use new macros for declaring and checking the payload struct as well as doing field swapping on-demand, dropping the SProc*() functions entirely
- add/use new macros for swapping reply fields on-demand, and sending the reply (incl. auto-filling some fields, ...)
When done, we've gained huge reduction in code complexity as well as size. Also, writing future extensions should become a lot easier.
WIP branch: https://gitlab.freedesktop.org/metux/xserver/-/tree/wip/swapping