Commit Graph

2893 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
4609d2e5e8 dix: Dispatch() separate variable for read result
Mixing result variables for separate things is making the code hard
to understand, so add a new local variable for temporarily storing
the result of ReadRequestFromClient().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-12 13:49:15 +01:00
Alan Coopersmith
2be080c4e3 dix: set errorValue correctly when XID lookup fails in ChangeGCXIDs()
dixLookupResourceByType always overwrites the pointer passed in as the
first arg, so we shouldn't use the union it's in after that to get the
requested XID value to put in the errorValue.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1857
Fixes: 2d7eb4a19b ("Pre-validate ChangeGC XIDs.")
Reported-by: Mouse <mouse@Rodents-Montreal.ORG>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2111>
2025-12-09 17:41:25 +01:00
Enrico Weigelt, metux IT consult
609ea42a62 include: don't install client.h anymore
not included by any drivers, so doesn't need to be in SDK anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-05 19:44:59 +01:00
Enrico Weigelt, metux IT consult
19ee44b607 treewide: drop including <dix-config.h> from private includes
All .c sources must include <dix-config.h> at the very first.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 19:50:44 +01:00
Enrico Weigelt, metux IT consult
36503b11b7 dix: consistenly name reply structs "reply" instead of "rep"
Preparation for future use of generic reply assembly macros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 16:28:06 +01:00
Enrico Weigelt, metux IT consult
01502a4ddd dix: request_priv.h: fix X_REQUEST_REST_COUNT_CARD16()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-04 14:26:41 +01:00
Enrico Weigelt, metux IT consult
a173278c4f dix: make SwapLongs() inline
a) trade a little bit of code size for speed
   (depending on exact caller, compiler might also optimize a lot)
b) reduce the need for exported, but non-public symbol

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-03 14:30:02 +01:00
Enrico Weigelt, metux IT consult
6a320e76cb dix: add macros for request handlers and swapping
add some macros for making request handlers and byte swapping easier:

    * X_REQUEST_HEAD_STRUCT(type) and X_REQUEST_HEAD_AT_LEAST(type)
      declare header struct pointers and check size
    * X_REQUEST_FIELD_CARD16(field)
      swaps a CARD16 (word) header field (if neccessary)
    * X_REQUEST_FIELD_CARD32(field)
      swaps a CARD32 (dword) header field (if neccessary)
    * X_REQUEST_REST_CARD16()
      swaps remaining CARD16 array payload (if necessary)
    * X_REQUEST_REST_CARD32()
      swaps remaining CARD32 array payload (if necessary)
    * X_REQUEST_REST_COUNT_CARD16(count)
      check swaps `count` CARD16 payload fields and checks size
    * X_REQUEST_REST_COUNT_CARD32(count)
      check swaps `count` CARD32 payload fields and checks size

How to use them:

    1. put X_REQUEST_HEAD_STRUCT() or X_REQUEST_HEAD_AT_LEAST() ontop of each Proc*()
    2. add X_REQUEST_FIELD_*() et al below, for all fields to be swapped and
       drop the corresponding SProc*()'s
    3. let the dispatchers call Proc*() instead of SProc*()

Notes:

    * the length field is already swapped before request handlers called

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-12-03 10:58:14 +01:00
Oleh Nykyforchyn
f4115e69eb dix: initialize all screens before proceeding to gc's, root windows etc
Current code walks along all screens and initializes screen resources,
then gc's, stipples, root windows for each of them, hence after
the first screen registering new private keys is no more possible.
This crashes modesetting driver if it is not initialized before others.

This patch makes screen resources for all screen initialize first, hence
all necessary private keys (including of the type PRIVATE_WINDOW) are
initialized before root windows are created.

Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
2025-12-03 09:24:33 +01:00
Marc-Alexandre Espiaut
e1b3bbafa8 dix: remove dixLookupBuiltinColor() unused screen argument
Signed-off-by: Marc-Alexandre Espiaut <76531574+malespiaut@users.noreply.github.com>
2025-11-28 18:43:40 +01:00
Enrico Weigelt, metux IT consult
e14d352661 dix: move GCAllBits define into private header
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 20:05:59 +01:00
Enrico Weigelt, metux IT consult
33729b1361 include: windowstr.h: unexport w*() macros
These aren't used by any drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:54:42 +01:00
Enrico Weigelt, metux IT consult
ff8d26df21 include: windowstr.h: unexport SameBackground() and SamBorder() macros
Not used by any drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:49:14 +01:00
Enrico Weigelt, metux IT consult
9b8d7d1eb9 treewide: don't include <region.h> anymore
Nothing in there that we need, include <regionstr.h> instead.
But keeping the file in place, until all external consumer have
been migrated.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 19:27:27 +01:00
Oleh Nykyforchyn
0230c6e074 dix: reexport ConnectionInfo for NVidia 390
This patch exports ConnectionInfo in server_priv.h and references
it in globals.c to force exporting.

Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
2025-11-27 17:06:36 +01:00
Enrico Weigelt, metux IT consult
85fae9bffb dix: inline SProcAllocColor()
Now that we have untwisted Xinerama side, it's trivial to inline
the few lines for byte-swapping into the actual handlers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 13:46:37 +01:00
Alan Coopersmith
e352fdecfe dix: handle allocation failure in DeviceFocusEvent()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../dix/enterleave.c:786:5:
 warning[-Wanalyzer-possible-null-dereference]:
 dereference of possibly-NULL ‘xi2event’

Fixes: 3f37923a72 ("Xi: send XI2 focus events." in Xorg 1.10.0)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2078>
2025-11-27 13:36:49 +01:00
Enrico Weigelt, metux IT consult
92a015504e dix: make BITMAP_SCANLINE_UNIT private
Not used by any external drivers, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 12:05:55 +01:00
Enrico Weigelt, metux IT consult
5532917d76 os: move AllowByteSwappedClients setting into DIX
Adding new source and header that's going to host all DIX
settings (set via cmdline or xf86 config file) in the future.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-27 10:44:23 +01:00
Enrico Weigelt, metux IT consult
8039c2cbf1 dix: unexport SwapLongs()
Not used by any external drivers, so no need to keep it in public SDK.
Since it's used by internal modules, still needs to be _X_EXPORT'ed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-25 18:26:02 +01:00
Mike Gelfand
f40bfb5ca9 dix: move include guards up to wrap the whole file
See: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
Signed-off-by: Mike Gelfand <mikedld@mikedld.com>
2025-11-21 15:20:11 +01:00
Enrico Weigelt, metux IT consult
d66dea68af dix: dixfonts: drop unused GetFontPath()
Not used anywhere, neither in Xserver nor in drivers, so no need
to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:26:32 +01:00
Enrico Weigelt, metux IT consult
95499a9525 dix: unexport enableIndirectGLX
Still needs to be _X_EXPORT'ed for internal modules, but
not supposed to be visible to external drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:25:41 +01:00
Enrico Weigelt, metux IT consult
6a1bdcedd3 dix: unexport DeleteProperty()
Not used by any external driver, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:35 +01:00
Enrico Weigelt, metux IT consult
40acb2d83e dix: unexport PrintPassiveGrabs() and PrintWindowTree()
These are only for internal debug output, not needed for drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:22:18 +01:00
Enrico Weigelt, metux IT consult
8059c260c2 dix: unexport XIUnregisterPropertyHandler() and XIDeleteAllDeviceProperties()
Not used by any external drivers, so no need to keep the exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:21:37 +01:00
Enrico Weigelt, metux IT consult
416f69eb88 include: misc.h: unexport lowbit() macro
Not used by any drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 19:20:07 +01:00
Enrico Weigelt, metux IT consult
44077ee11c dix: unexport screenIsSaved and HasSaverWindow()
These aren't used by any external drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:52:23 +01:00
Enrico Weigelt, metux IT consult
b0ac921156 dix: unexport GrabInProgress
Only internally within OS layer and screen saver logic,
so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 17:42:29 +01:00
Enrico Weigelt, metux IT consult
064e5f2ddf os: drop OsCleanup()
Since we're always terminating now, everbody can call UnlockServer()
directly, so we don't need that extra function anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-20 11:19:02 +01:00
Enrico Weigelt, metux IT consult
f27e12c918 dix: drop DE_RESET and associated cmdline args
Drop the -reset flag, so Xserver now either simply continues (w/o going
through internal reset) when last client disconnected or terminates
when -terminate is given.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-18 18:22:25 +01:00
Marc-Alexandre Espiaut
45ff802682 dix: _colormap_find_resource(): fix -Wunused-parameter warning
Signed-off-by: Marc-Alexandre Espiaut <76531574+malespiaut@users.noreply.github.com>
2025-11-18 13:30:32 +01:00
Marc-Alexandre Espiaut
0588be6d1e dix: FreeClientPixels(): fix -Wunused-parameter warning
Signed-off-by: Marc-Alexandre Espiaut <76531574+malespiaut@users.noreply.github.com>
2025-11-18 13:30:32 +01:00
stefan11111
0ec0f00c23 glx: revert cb85ceae2d
This commit broke glx after server reset.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-11-11 10:46:29 +01:00
stefan11111
631dc9d275 dix: partially revert 8399c4e263
Turns out that glx does need this one.

Assuming no external modules need this,
it should be fine to keep this in a private header.

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-11-11 10:46:29 +01:00
Enrico Weigelt, metux IT consult
ec3232e36e dix: move ReplyNotSwappd() out of public header
Internal, non-publich function - should not be in public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-11 10:43:11 +01:00
Enrico Weigelt, metux IT consult
f813cb569f dix: move swaprep.h and swapreq.h into dix
These aren't public includes, so they're better placed in dix.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-11 10:42:40 +01:00
Enrico Weigelt, metux IT consult
037a2e5675 include: unexport CURSOR_BITS_SIZE() and CURSOR_REC_SIZE() macros
Not used by any drivers, so no need to keep them public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-08 10:45:43 +01:00
Enrico Weigelt, metux IT consult
94f7925f01 dix: move IMAGE_BUFSIZE define out of public header
It's just a tuning parameter (that nobody touched for aeons) for
DoGetImage(), inside dix/dispatch.c

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-07 09:32:17 +01:00
Enrico Weigelt, metux IT consult
03dcb626fe dix: UngrabServer(): clear grabClient pointer
When ungrabbing, clear the grab pointer, so no stale data left
in here.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-05 17:16:42 +01:00
Enrico Weigelt, metux IT consult
21db844ea1 dix: MakeRootTile(): constify from field
It's assigned a const char* value and not writing into it,
so it should be const, too (compiler correctly warning about that)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-05 12:16:06 +01:00
clhin
7468cd4ee0 dispatch.c: const correctness 2025-11-04 10:48:52 +01:00
clhin
b47576420f window.c: const correctness 2025-11-04 10:48:52 +01:00
Enrico Weigelt, metux IT consult
cf105bc990 dix/Xinerama: untwist X_AllocColor request handling
Instead of internally faking requests, factor out the actual logic
into separate function, which is getting everything it needs as
parameters, so no need to fiddle with request buffer anymore.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-11-03 17:24:24 +01:00
Enrico Weigelt, metux IT consult
45aa28d4d2 dix: inline SProcChangeProperty()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-31 13:06:11 +01:00
Enrico Weigelt, metux IT consult
0fbb681fce treewide: use helper dixGetScreenPtr() for retrieving ScreenPtr's
Instead of directly accessing the global screenInfo.screens[] array,
let everybody go through a little inline helper. This one also checks
for array bounds - if the screen doesn't exist, return NULL.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-30 09:44:24 +01:00
Enrico Weigelt, metux IT consult
e23f70624f dix: privates: update docs on dixRegisterPrivateKey()
a) move to doxygen-style docs, inside the header instead of code
b) mention that the function can be called many times with the
   same parameters (already registered keys are silently tolerated)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-29 11:45:04 +01:00
Tautvis
a581ba5964 dix: dixFreeScreen call hookPostCreateResources too
Call DeleteCallbackList(&pScreen->hookPostCreateResources) during
dixFreeScreen, because otherwise it will be heap-use-after-free during
DeleteCallbackManager call.

Signed-off-by: Tautvis <gtautvis@gmail.com>
2025-10-29 11:41:26 +01:00
Enrico Weigelt, metux IT consult
04d4986004 dix: split ProcCreateWindow() into upper and lower half
In order to reduce complexity of wrapped core request handlers with PanoramiX,
split the ProcCreateWindow() function into two pieces: the upper half is the
usual (non-PanoramiX) handler, while the lower one is what's called by both
the usual handler, as well as the PanoramiX' one.

We're already passing in the request parameters as separate pointers, so
follow-up commits can easily change PanoramiX handler to not tweaking the
request buffer directly anymore. Another one is letting PanoramiXCreateWindow()
be called by ProcCreateWindow explicitly (when enabled), so we don't need to
wrap the core request proc vector anymore. Once that's done, the swapping can
also be moved into ProcCreateWindow().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-29 11:03:19 +01:00
Enrico Weigelt, metux IT consult
48123076f9 dix: inline SProcDeleteProperty()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-10-29 10:56:22 +01:00