Instead of memset()ing all the structs and then assigning (overwriting)
invidual fields one by one, use static init and let the compiler find out
on its own how to do it the best way.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The macro will automatically return BadAlloc if the buffer is broken,
otherwise Success. Thus, we don't need extra prior rpcbuf check.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
At this point just use it as allocator, so we can use the
X_SEND_REPLY_WITH_RPCBUF() macro for final sending.
Follow-up commits will change the whole call stack to operate on
x_rpcbuf_t directly, so it's also doing the byte-swap for us.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add extra check for comparing the actually written sub-payload sizes
with their previously computed ones. This is meant for troubeshooting
while still stabelizing the previous, not entirely trivial commits.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add and use macro X_REPLY_HEADER_UNITS() for computing how many
extra protocol units are needed for a reply header (for .length field)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Use x_rpbuf_t instead of raw buffer for assembling and byte-swapping
indicator map payload.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Since no consumer of this rpcbuf is writing directly to the underlying
buffer space anymore, there's no need to explicitly make room.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Use generic macro for sending out final reply.
Also dropping our own unnecessary size payload computation - rpcbuf
already giving us this value.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Now that we're entirely operating on x_rpcbuf_t, we can use generic
macro for the whole final write out, including setting standard
reply header fields.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Instead of operating on a raw buffer, use x_rpcbuf_t to assemble the
compat map payload.
ProcXkbGetCompatMap() now can directly operate on generic x_rpcbuf_t
and doesn't need it's own private buffer management.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The amount of data written by XkbAssembleMap() is already known rpcbuf,
so no need for additionally computing this our own anymore.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
We've been adding the individual sub-packet's payload bytes *after*
the swapping, which is leading to totally wrong sizes.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The global (exported) serverGeneration field is `unsigned long`, while
many other places copy it and compare it two other integer types, eg.
plain `int` (which is signed). Even if it's unlikely ever reaching such
high number of generations that it will ever make trouble, it's still
a good idea to clean this up and use the same type everywhere.
For clearity, introducing a typedef `x_server_generation_t` which is
used everywhere, instead of raw `unsigned long`.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Print out a warning when actually written payload length doesn't mactch
the previously computed one.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As we now have x_rpcbuf, we can use it here, instead of meddling
with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
As it's caller now has x_rpcbuf_t, we can use it here, instead of
meddling with pre-allocated buffer space directly via raw pointer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The keymap assembly machinery is a horribly complicated machinery,
because often whole replies with variable sized payloads can be nested
into each other. It's time to use x_rpcbuf_t for that, but's is not an
easy thing to do and really a huge change - therefore doing this in small
and easy to digest step.
At first, let XkbAssembleMap() operate on a x_rpcbuf_t. But for now just
let it use the x_rpcbuf_t's raw buffer directly (because it's callees cant
work on this yet) - thus XkbAssembleMap() yet need to make enough room
in the buffer before calling in.
For the time being we're allocating far too much (because calculating
the actually need amount would be too complicated here) and having an
extra memcpy(). But it's just an intermediate step anyways - subsequent
commits will convert everything down the whole call chain into using
x_rpcbuf_t operations, so that extra overhead can be dropped again later.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
All source files need to include it anyways, so no need to include it here,
and neither having an extra check for HAVE_DIX_CONFIG_H
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This is a regression first caused by 182404fde6
that sends back the old xkb data instead of the new one.
This causes a mismatch in the data and size calculations between the
XkbComputeGetMapReplySize that is called above that calculates the size
of the reply and XkbAssembleMap that sets the data for the reply.
Without this fix this error is seen when running setxkbmap fr:
"Error loading new keyboard description".
Fixes setxkbmap error described in #180
Signed-off-by: dec05eba <dec05eba@protonmail.com>
* xled change tested with `xset led named "Scroll Lock"`
* modesetting change tested with `xrandr --output DP-1 --gamma 0.5:0.5:0.5`.
Without this fix that command does nothing
* xvmc change tested with `mpv --vo=xv video.mp4`
Of the currently reported issues this fixes#104
Signed-off-by: dec05eba <dec05eba@protonmail.com>
This fixes a regression in 5499a2999 (xkb: let SendDeviceLedFBs() fill buffer instead of writing directly, 2024-07-16).
We need to write the whole buffer, and the updated length has to take
into consideration that `sz` now contains `led_len` so we need to
subtract that or properly calculate the remaining size.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>