Commit Graph

2776 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
8cfcb072d2 dix: ProcListHosts(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-04 10:22:12 +02:00
Enrico Weigelt, metux IT consult
15340ce053 dix: ProcQueryColors(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-04 10:22:00 +02:00
Enrico Weigelt, metux IT consult
a41114cbe7 dix: ProcListInstalledColormaps(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 17:12:11 +02:00
Enrico Weigelt, metux IT consult
c3df0f0ed5 dix: DoGetImage(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF()
for sending it all out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 15:11:26 +02:00
Enrico Weigelt, metux IT consult
61f9234ee8 dix: rpcbuf: _X_EXPORT some functions for internal use
_X_EXPORT'ing some x_rpcbuf_clear() and x_rpcbuf_write_CARD8s() just for
internal use (eg. glx) - those are *NOT* supposed to be called by any
external modules/drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 11:20:59 +02:00
Enrico Weigelt, metux IT consult
065f8d4d75 dix: unexport internal QueryFont() function
This function is internal to DIX (used for assembling XQueryFont replies
and not used by any drivers (not even proprietary NVidia), and really
shouldn't ever called by them at all. It's been one the many victims of a
really unthoughtful mass export back 17 years ago.

That'S a necessary step for refactoring the RPC reply mechanics.

Since it's never used by any driver at all, we can easily to this change
within the current ABI level.

Fixes: d6cbd4511e
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:31:44 +02:00
Enrico Weigelt, metux IT consult
2aec9a0b73 dix: rpcbuf: add x_rpcbuf_write_CARD64() and x_rpcbuf_write_CARD64s()
Add functions for writing (and byte-swapping) CARD64 values.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:31:30 +02:00
Enrico Weigelt, metux IT consult
7655ee2631 dix: drop unused CopySwap32Write()
Not used anywhere, neither exported, so no need to keep it
around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:29:35 +02:00
Enrico Weigelt, metux IT consult
3107056193 dix: doListFontsWithInfo(): inline SwapFonts() call
As preparation for moving doListFontsWithInfo() (and it's callers) to
x_rpcbuf_t, inline the SwapFonts() call into the caller function.

SwapFonts() has several problems, eg. directly operating on a buffer that's
holding xQueryFontReply struct (which isn't the correct one, just happens to
match) as well as the whole payload.

We first need to get them out of the way, before we can split off the reply
into the (statically declared) header struct and the (x_rpcbuf_t-filled)
payload.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:29:17 +02:00
Enrico Weigelt, metux IT consult
4ca0274f3e dix: cursor: NULL check in ScreenRec->UnrealizeCursor calls
just for being cautious.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 09:28:58 +02:00
Enrico Weigelt, metux IT consult
f8ad69698a treewide return code of X_SEND_REPLY_WITH_RPCBUF()
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>
2025-09-02 12:48:50 +02:00
Enrico Weigelt, metux IT consult
ea3ef55be1 dix: dixfonts: doListFontsWithInfo(): use X_SEND_REPLY_SIMPLE()
Use X_SEND_REPLY_SIMPLE() for writing out the trivial empty reply.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-01 15:28:05 +02:00
Enrico Weigelt, metux IT consult
46b4154517 dix: dixfonts: doListFontsAndAliases(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and send it out via
X_SEND_REPLY_WITH_RPCBUF() macro.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-01 15:27:41 +02:00
Enrico Weigelt, metux IT consult
d04c60276a dix: devices: ProcGetMotionEvents(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-01 15:27:21 +02:00
Enrico Weigelt, metux IT consult
ae4912f837 dix: drop obsolete Swap32Write()
Not used anywhere, neither exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 15:55:40 +02:00
Enrico Weigelt, metux IT consult
4aff0544ea dix: screen_hooks: drop extra ; on DECLARE_SCREEN_HOOK()
This isn't allowed by C standard, so getting warnings using -pedantic.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 14:18:39 +02:00
Enrico Weigelt, metux IT consult
37ebc7d74b treewide: explicitly cast %p printf parameters to void*
Do it the ISO C way, so -pendantic is shouting a little bit less.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 10:03:34 +02:00
Enrico Weigelt, metux IT consult
4160338f3a dix: devices: use x_rpcbuf_t for payload assembly
Use x_rpcbuf_t for reply payload assembly, so we can uniformly use the
X_SEND_REPLY_WITH_RPCBUF() macro for final write out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 09:59:36 +02:00
Enrico Weigelt, metux IT consult
7689a31866 dix: rpcbuf: add x_rpcbuf_write_INT32s()
litle wrapper for directly writing INT32 arrays w/o signess warnings.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-28 17:22:30 +02:00
stefan11111
70f3b3abf3 dix: fix X_SEND_REPLY{,_WITH_RPCBUF} macros
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-08-27 09:46:33 +02:00
Enrico Weigelt, metux IT consult
1102a0b6ce dix: let X_SEND_REPLY_SIMPLE() return X11 result code
Let X_SEND_REPLY_SIMPLE() macro return the X11 result code `Success`.
No change in semantics, just allowing a bit shorter typing, so one
can now directly write `return X_SEND_REPLY_SIMPLE(...)` in one line.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-25 16:47:59 +02:00
callmetango
d7c11245b0 dix: remove duplicate Xdefs include in dix_priv.h
Fixes: #800
Signed-off-by: callmetango <callmetango@users.noreply.github.com>
2025-08-25 14:42:38 +02:00
Enrico Weigelt, metux IT consult
29e1905935 dix: fix X_REPLY_HEADER_UNITS()
Needs to be bytes_to_int32() instead of pad_to_int32(), since we want
the amount of units instead of bytes here.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-25 11:48:03 +02:00
Enrico Weigelt, metux IT consult
35d72a759a dix: let X_SEND_REPLY_WITH_RPCBUF() return status code
Check for rpcbuf error and return BadAlloc then, otherwise return Success.
This way, callers don't need to check their rpcbuf for error on their own
anymore, but can just do return X_SEND_REPLY_WITH_RPCBUF(...).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-25 11:25:10 +02:00
Enrico Weigelt, metux IT consult
6ad01ebfc7 dix: devices: use X_SEND_REPLY_SIMPLE()
Use X_SEND_REPLY_SIMPLE() for sending out simple replies.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-24 12:40:41 +02:00
Enrico Weigelt, metux IT consult
be6f403100 dix: use X_SEND_REPLY_SIMPLE()
Use X_SEND_REPLY_SIMPLE() for sending out simple replies.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-24 12:40:34 +02:00
Enrico Weigelt, metux IT consult
a2163f1aab dix: replace WriteRpcbufToClient() by X_SEND_REPLY_WITH_RPCBUF() macro
Use the new X_SEND_REPLY_WITH_RPCBUF() macro for final reply write out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-24 12:11:17 +02:00
stefan11111
90846d49cc xfree86: add (optional) ScreenRec padding for legacy Nvidia driver
Commit 3cb3024fea removed pScratchPixmap field
in ScreenRec, which broke legacy Nvidia (proprietary) drivers (470.x), thus
we should add an empty/dummy field here, to ensure correct padding. But this
would break ABI again - can't do that within minor release line.

As compromise, adding a *build time* option CONFIG_LEGACY_NVIDIA_PADDING for
this, so operators/packagers can opt-in to this change.

As it breaks ABI, the option is disabled by default until the next major release
and intended for EXPERTS ONLY who need nvidia390 or nvidia470 drivers.

Note that ALL DRIVERS should be rebuild if it is applied!

This compile-time option, along with the hacks needed to support it
in a non-abi-breaking way, should be droppen in the next major release.

Co-authored-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>

Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-22 17:02:12 +02:00
Enrico Weigelt, metux IT consult
bbccfab253 dix: rpcbuf: fix x_rpcbuf_write_INT32()
The typecast was wrong (copy-paste error), needs to be CARD32 instead of CARD16.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-22 15:53:25 +02:00
Enrico Weigelt, metux IT consult
7c3ddc80ef dix: drop obsolete WriteSwappedDataToClient() macro
This macro isn't and shouldn't be used anymore, so get rid of it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-22 15:45:47 +02:00
Enrico Weigelt, metux IT consult
d6089c52c3 treewide: macro for computing extra units needed for reply header
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>
2025-08-22 14:14:32 +02:00
Enrico Weigelt, metux IT consult
f9fba638cf dix: add macro X_SEND_REPLY_SIMPLE() for sending simple replies
This macro fixes up a given reply header, computes it's full size
and sends it out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-21 18:32:45 +02:00
Enrico Weigelt, metux IT consult
658d2db226 dix: rpcbuf: add x_rpcbuf_write_INT32()
litle wrapper for directly writing INT32 w/o signess warnings.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-21 17:42:04 +02:00
Enrico Weigelt, metux IT consult
7f648df8af dix: rpcbuf: add x_rpcbuf_write_rect() for writing RECTANGLE PDU
The `RECTANGLE` PDU is pretty common, so it's good to have a helper for
writing this, so it doesn't need to be open-coded everywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-20 11:37:47 +02:00
Enrico Weigelt, metux IT consult
2edb06c8bc dix: rpcbuf: add x_rpcbuf_write_rpcbuf_pad()
This is writing the contents of source rpcbuf into the target one,
pads it and finally clears the source buffer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-20 11:37:02 +02:00
Enrico Weigelt, metux IT consult
66311c6d51 dix: rpcbuf: add x_rpcbuf_write_counted_string_pad()
Add a helper for writing pascal-type strings: the counter is written
as CARD16, then followed by the string characters (w/o zero), and
finally everything padded up to full protocol units.

This encoding is used in various places throughout the Xserver,
eg. in xkb.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-20 11:13:07 +02:00
Enrico Weigelt, metux IT consult
15fdd0ae20 dix: fix X_SEND_REPLY_WITH_RPCBUF()
We need to call bytes_to_int32() instead of pad_to_int32(),
otherwise our computation is totally broken.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-18 19:38:15 +02:00
Enrico Weigelt, metux IT consult
0b7194c9bc dix: add X_SEND_REPLY_WITH_RPCBUF() macro
This macro is sending a reply header struct and rpcbuf payload
all in one shot. It also automatically computes the payload lengths
as well as also filling common fields like `type` and `sequenceNumber`

A typical call site looks like this:

>    int ProcFooRequest(ClientPtr client) {
>
>        [ ... ]
>
>        X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
>        return Success;
>    }

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-18 11:16:23 +02:00
Enrico Weigelt, metux IT consult
361b576c48 dix: canonical walkScreen variable on screen list iterations
When iterating screen lists, consistently use the same variable name
`walkScreen` for holding current screen pointer everywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-18 10:52:49 +02:00
Enrico Weigelt, metux IT consult
2fddefcf8c dix: use x_rpcbuf_t in ProcListProperties()
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-15 19:52:07 +02:00
Enrico Weigelt, metux IT consult
5d8f149a57 dix: fix memory clearing in dix_main()
Clearing of screens and gpuscreens pointer list on teardown has been wrong.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-15 14:27:39 +02:00
Enrico Weigelt, metux IT consult
91bc0ff6b2 dix: use x_rpcbuf_t in ProcGetKeyboardMapping()
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-15 13:34:26 +02:00
Enrico Weigelt, metux IT consult
eb04c7a1b3 dix: use x_rpcbuf_t in ProcQueryTree()
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-15 12:58:06 +02:00
Enrico Weigelt, metux IT consult
aac7a9330a dix: use x_rpcbuf_t in ProcGetProperty()
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-15 00:04:10 +02:00
Enrico Weigelt, metux IT consult
8a2dfa1aba dix: macro for computing extra units needed for reply header
Add 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>
2025-08-14 19:17:39 +02:00
Enrico Weigelt, metux IT consult
a95ae61658 dix: rpcbuf: add rpcbuf_write_INT16()
Just a convenience wrapper for writing an INT16.
Technically it's really the same as CARD16, but we still need a typecast
in order to not getting a compiler warning on int signedness mismatch.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-14 19:00:45 +02:00
Enrico Weigelt, metux IT consult
e07a939765 dix: rpcbuf: add x_rpcbuf_pad() for padding the buffer
New function for padding the buffer to full protocol units granularity:
If the current write position isn't at 4-byte granularity, it reserves
the remaining number of bytes (ie. writing zeros), in order to make the
next write align to 4-byte granularity again.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-14 12:44:26 +02:00
Enrico Weigelt, metux IT consult
03928dea4b panoramiX: don't use FOR_NSCREENS_FORWARD_SKIP() anymore
in preparation of upcoming new iterator macros, phase out
FOR_NSCREENS_FORWARD_SKIP, so we don't need an additional macro
for just the case where first screen is skipped.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-14 12:10:27 +02:00
Enrico Weigelt, metux IT consult
34c3a9c7e2 treewide: fix serverGeneration int type mismatch
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>
2025-08-13 11:52:03 +02:00
Enrico Weigelt, metux IT consult
3af53d474f dix: let CreateGCperDepth() accept ScreenPtr instead of screen id
It's only caller already has the ScreenPtr, so it doesn't make any sense
passing in the screen number and let that function retrieve the pointer
on its own again.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-12 11:09:43 +02:00