Commit Graph

19000 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
9f2d7390b1 randr: ProcRRListOutputProperties(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.

This also allows even further simplifications by using generic macros
for the request send path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
c6e3490f96 randr: ProcRRGetCrtcGamma(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.

This also allows even further simplifications by using generic macros
for the request send path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
972dbf7bfd randr: ProcRRGetProviders(): use stack for tiny temporary buffer
The reply payload buffer is very small and short-lived, so we can easily
use a local dynamic array for that, thus saving an extra heap alloc/free.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
b870d60762 randr: ProcRRGetProviderProperty(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.

This also allows even further simplifications by using generic macros
for the request send path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
15779f3f25 randr: ProcRRGetOutputProperty(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.

This also allows even further simplifications by using generic macros
for the request send path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
45387506d5 randr: ProcRRGetOutputProperty(): rename reply struct to "rep"
Harmonize it with all the other reply struct fields, so we can later
use generic macros for final preparation and writeout.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
c2702074fc randr: RRCreateProviderProperty(): use calloc()
We can rely on everything being cleared. And usually even faster, as the
compiler can emit optimized instructions for clearing a whole block at once.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
6e8abf551b randr: RROutputCreate(): use calloc()
We can rely on everything being cleared. And usually even faster, as the
compiler can emit optimized instructions for clearing a whole block at once.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
26782023bc randr: ProcRRGetMonitors(): collect reply payload in temporary buffer
Instead of arbitrary count of individual WriteToClient() calls on small
chunks, collect the whole payload in a buffer and write it out all at once.

This also makes possible to use generic macros for reply sending, as well
as further simplifications in the write-out path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
01ecb28de8 randr: ProcRRGetMonitors() use SwapLongs instead of callbacks
WriteSwappedDataToClient() calls a callback on each single field.
We can have it easier and more efficient by just using SwapLongs()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
b0194e9eb5 randr: ProcRRGetCrtcTransform(): split reply header and payload
Using struct initializer for the reply header and only allocating the
payload on heap. This allows using generic macros for reply preparation
and send-out later.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
a52c519c12 randr: ProcRRGetCrtcInfo(): use locally scoped variables
Improve readability by moving the variables into local scopes.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
cbef3c8e63 randr: use struct initializer for reply structs
Improve readability, move the declarations to where they're needed first
and get rid of extra individual assignments. In some cases this should also
allow the compiler to produce a bit more efficient code.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
1089dc3e21 randr: RRCrtcCreate(): drop unnecessary zero assigments
The struct is already zero'ed out by calloc(), so no need to additionally
clear individual fields.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
cc6a76545b randr: use explicit case statement instead of SProcRandrVector table
No need to go indirectly through a vector table, since everything's fixed
anyways. It's not a pretty robust programming style: any changes need great
care, in order to not mix up things.

Replacing this by direct switch/case statement, which is using the defines
from the xrandr protocol headers. Also adding a little bit more protection
against subtle programming errors and reducing cognitive load (source size)
on understanding the code by using a tiny macro for deducing define name and
function name from the request's name.

This approach actually uncovered some subtle bug that had been waiting in
the dark for over 15 years.

As collateral benefit, getting a tiny bit better performance.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
da336d0fe3 randr: use explicit case statement instead of ProcRandrVector table
No need to go indirectly through a vector table, since everything's fixed
anyways. It's not a pretty robust programming style: any changes need great
care, in order to not mix up things.

Replacing this by direct switch/case statement, which is using the defines
from the xrandr protocol headers. Also adding a little bit more protection
against subtle programming errors and reducing cognitive load (source size)
on understanding the code by using a tiny macro for deducing define name and
function name from the request's name.

This approach actually uncovered some subtle bug that had been waiting in
the dark for over 15 years.

As collateral benefit, getting a tiny bit better performance.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
00ef5b1f5f randr: let SProc*'s call their Proc*'s directly
No need to go indirectly through an vector table. It's much clearer and
easier to understand when calling them directly. And a tiny bit performance
improvement as collateral benefit.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
7d6372ea3b randr: RRScreenInit(): drop unnecessary zero'ing
The whole struct is already allocated by calloc(), so no need to explicitly
zero-out individual fields.

Fixes: 479b2be4ba - Clear allocated RandR screen private structure
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
1534692c98 Xext: panoramiX: PanoramiXGetImage() reply payload in one block
Simplify writing reply payload into just one block.
This also makes further simplifications by subsequent patches easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
6bc31594c2 dri: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
e6de0be04c dri: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
ac30288aab dri: ProcXF86DRIGetDrawableInfo() allocate temporary buffer on stack
No need for going through heap, stack is also fine.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
c496df2f29 dri: use static struct init on declaration & drop useless assignments
Make the code a bit easier to read by using initialization of the reply
structs, at the point of declaration. Most of them aren't written to later,
just passed into WriteReplyToClient(). Also dropping some useless zero
assignments (struct initializers automatically zero-out unmentioned fields).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
026b19af56 dri: report failed memory allocation
ProcXF86DRIGetDrawableInfo() should report failed memory allocation instead
of pretending everything's okay.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
9d40106aaa dbe: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
c1139d2524 dbe: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
cf30667163 dbe: ProcDbeGetVisualInfo() collect payload in buffer before writing
The payload lengths is already known, so we can easily collect the data
in a stack buffer and only need one WriteToClient() operation.

This also clears the road for further simplification/unification of the
reply sending code, coming with follow-up commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
d8d430c11c dbe: simplify temporary buffer allocation via local stack
Small buffers easily fit on stack, so their allocation can be simplified.
No need to go through heap and have extra free() calls on each return point.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
8bf0c3d716 dbe: fix byte swapping in SProcDbeSwapBuffers()
The loop forgot to move the SwapInfo pointer, so the same list entry
gets swapped over and over again, while the remaining ones get ignored.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:07 +02:00
Enrico Weigelt, metux IT consult
5ac24f0c0b xkb: use new macros for byte swapping in network buffers
Use the new macros for doing byte-swapping in network buffer structs
which aren't requests or reply structs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
018f941b2c xkb: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
5f17708a84 xkb: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
1030ba58a2 dri3: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
3ced8a2501 dri3: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
62d48e1720 Xext: panoramiX: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
4a0a6e963d Xext: panoramiX: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
d93666575e Xext: xvmc: enable swapped requests 2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
fe5b9f0a73 Xext: xvmc: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
f4c75bd036 Xext: xvmc: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
ccbb4315a1 xfixes: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
97186ab87c xfixes: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
64012bd401 Xi: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
1dd0382acb Xi: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
43ef04bc86 composite: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
4bc3a24388 composite: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
f2b1a6e555 damage: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
ba60f262e3 damage: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
a5df5f98fa Xext: xv: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
41926b5ee7 Xext: xv: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping
much easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00
Enrico Weigelt, metux IT consult
f53d96df93 Xext: xtest: use REPLY_*() macros for preparing / sending replies
Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-08-29 11:35:06 +02:00