Compare commits

...

134 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult c14c7ec016 WIP: clean up forgotten comment 2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 48918f28d9 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 165eb1be2b 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult d03d79f96b 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 32f6a22dd1 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult c704eb884a 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult bbfdb50b5c 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 2a63c0911f 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 0c3d3856cc 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 3f37b07864 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult f1c658e581 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 1425d94daa 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 71cbcb6f02 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 95301df1a9 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult 9c6271258c 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>
2025-06-26 11:25:45 +02:00
Enrico Weigelt, metux IT consult dc39130899 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult a5f44e4c59 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 587e00e167 Xext: xvmc: enable swapped requests 2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 18331c6d19 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 9ab956a7ef 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 67292b02e3 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 9b8638da17 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult c2270f38b3 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 83a63a64a0 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult adefed6226 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 7baf8767a0 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 8ca929a021 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 52bf89e19f 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult c729bfd1f9 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 2892b49d26 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 757f6ab8bc 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult d929424514 Xext: xtest: 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult a9f50509bc Xext: selinux: 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 105ee0f8ac Xext: selinux: 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult a45230afac Xext: xres: 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>
2025-06-26 11:25:44 +02:00
Enrico Weigelt, metux IT consult 153361bdc9 Xext: xres: 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>
2025-06-26 11:25:43 +02:00
Enrico Weigelt, metux IT consult fcb1bac94c Xext: xf86bigfont: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 9cc70cd9ff Xext: xf86bigfont: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult c133b094ef Xext: xcmisc: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6f360d77bb Xext: xcmisc: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 0bf0da7b90 Xext: vidmode: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 99e8b56421 Xext: vidmode: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 75328e8356 Xext: sync: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 5cded6356d Xext: sync: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 034791c693 Xext: security: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 35e8a37b17 Xext: security: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 03b8cb506f Xext: geext: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult ff1cb0df89 Xext: geext: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 07ce669504 Xext: shm: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult bac5e1fa2d Xext: shm: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult a7f9bcaf39 Xext: bigreq: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult f906f3afc4 Xext: bigreq: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 87c9317714 Xext: shape: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 7c92bf3937 Xext: shape: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6f6379ff54 Xext: saver: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 0fde105e38 Xext: saver: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 428855b0df Xext: dpms: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 9614b41afb Xext: dpms: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 893f56f6b0 include: dix.h: add macros for request handlers and swapping
add some macros for making request handlers easier:

    * REQUEST_HEAD_STRUCT() declares a struct and checks size (assuming
      length field already had been swapped)
    * REQUEST_FIELD_CARD16() swaps a CARD16 (word) if neccessary
    * REQUEST_FIELD_CARD32() swaps a CARD32 (dword) if neccessary

How to use them:

    1. move swapping of lengths field into the SProc*Dispatch() and drop it
       from the individual SProc*()'s
    2. put REQUEST_HEAD_STRUCT() ontop of each Proc*()
    3. add REQUEST_FIELD_*() below, for all fields to be swapped and
       drop their swapping from the SProc*()'s
    4. clean up unnecessary wrappers (SProc*()'s just be just call the
       corresponding Proc*() by now)
    5. let demux SProc just swap length field and call the normal Proc*Dispatch()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 1d9c412683 Xext: panoramiX: ProcXineramaQueryScreens(): 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult b619f19c84 Xext: selinux: allocate reply buffer on stack
Simplify reply buffer in SELinuxSendItemsToClient() by putting it on stack.
No need to go through heap and free it later, if the compiler can do all
the work for us.

This also allows further generalizations of reply sending code by upcoming
commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 8501dda10d (submit/cleanup-xi) test: Xi: make sure client swapped flag is reset
Some test cases are recycling the ClientRec between swapped/unwapped runs.
Make sure the Client's swapped flag is always reset in those cases.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 63f510ebf2 (submit/cleanup-xi) Xi: use stack allocation for temporary buffers
Small buffers easily fit on stack, which is much faster (just moving SP),
and alloca()'ed buffers are cleaned up automatically on function leave,
no extra free() needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult e7262542d5 (submit/cleanup-xi) Xi: use static reply struct init on declaration
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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult d84af813a2 (submit/cleanup-xi) Xi: simplify dispatcher
The dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

It's also much cleaner to use the defines from proto headers instead of
raw numbers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult d41b209a19 (submit/cleanup-damageext) damage: hand in request struct into doDamageCreate() and PanoramiXDamageCreate()
Saves us a little bit of duplicate request checking.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 52542da36c (submit/cleanup-damageext) damage: simplify dispatcher
These dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6da5284195 (submit/cleanup-damageext) damage: don't block requests when version not requested yet
The original intention was negotiating versions before any further requests
can be processed, so requests that might become incompatible in future versions
still can be dispatched correctly. But practically that's never been the case:
there's just one major version, and it's unlikely that a new *major* version
(that might be incompatible with the current one, using same request codes for
different things) will come in the forseeable future.

So this extra logic isn't practically needed and just complicates dispatching.
Dropping it clears the road for further simplification of the dispatcher.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 8ef462c58a (submit/cleanup-damageext) damage: untwist Xinerma handling
The diffenciation between Xinerama and single screen version is by tweaking
call vectors unncessarily complicated: it the only reason why these are
needed in the first place. Finally, it's just about one function, so it's
much easier just branching off in ProcDamageCreate() in case of Xinerama
is enabled.

This also clears the road for further simplification of the dispatcher.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult f8d6a480e4 (submit/cleanup-damageext) damage: minor code formatting cleanups
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 8ca913faa2 (submit/cleanup-shm-dispatch) Xext: shm: move client local check into procs
Move extra complexity out of the dispatch functions, so they're
really just switch/case statements calling the actual handler procs.
Preparation for further steps.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult c2760879c2 (submit/cleanup-shm-dispatch) Xext: shm: simplify dispatcher
These dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6bd069b343 (submit/cleanup-xv-dispatch) Xext: xv: ProcXvListImageFormats(): write reply payload at once.
Collect up the puzzle piezes of the reply payload into to a temporary struct,
so we can send it as one block. This allows for further simplifications by
subsequent commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 165e48e286 (submit/cleanup-xv-dispatch) Xext: xv: ProcXvQueryAdaptors(): write reply payload at once.
Collect up the puzzle piezes of the reply payload into to a temporary struct,
so we can send it as one block. This allows for further simplifications by
subsequent commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 50813e93c6 (submit/cleanup-xv-dispatch) Xext: xv: 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>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 014954c3f7 (submit/cleanup-xv-dispatch) Xext: xv: ProcXvQueryAdaptors() use local stack buffer
Simplify sending by collecting in a local scoped buffer, so only one
WriteToClient() call is needed. This also makes further simplifications
by upcoming patches easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 10510cd528 (submit/cleanup-xv-dispatch) Xext: xv: simplify reply byte-swap
The way it's currently done, indirectly via macros calling dedicated
functions, is unnecessarily complicated. Simply inline it, just like
(almost) all the other extensions are doing it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 70f77c510a (submit/cleanup-vidmode-dispatch) Xext: vidmode: untwist ProcVidModeGetAllModeLines() and use stack buffer
The ProcVidModeGetAllModeLines() is a bit complicated, because reply structs
differ depending the active protocol version. In order to make it easier to
understand and allow further simplification of the request/reply marshalling
(see ticket #1701), splitting the two protocol versions into separate functions.

Also collecting the whole payload in a stack buffer (size is already known
anyways), in order to save arbirary number of individual WriteToClient() calls,
but send out the whole reply in one pass, which in turn allows further
simplifications in the sending path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 0dd817f62c (submit/cleanup-vidmode-dispatch) Xext: vidmode: ProcVidModeGetMonitor(): write reply payload at once.
Collect up the puzzle piezes of the reply payload into to a temporary struct,
so we can send it as one block. This allows for further simplifications by
subsequent commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult cfa82b85b0 (submit/cleanup-vidmode-dispatch) Xext: vidmode: ProcVidModeGetMonitor() simplify swapping/writing
We can simply call SwapLongs() before writing out the CARD32 arrays.
No need using for complicated call back logic.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult d93b4614f0 (submit/cleanup-vidmode-dispatch) Xext: vidmode: ProcVidModeModModeLine(): move len variable into branch scope
Semantically these are separate values in each branch any only used there,
so it's a bit more clean to move the declaration into the branches.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult ac5cdc3680 (submit/cleanup-vidmode-dispatch) Xext: vidmode: drop unnecessary if (client->swapped)
The WriteSwappedDataToClient() already checks whether client is swapped
and directly calls WriteToClient() if it's not.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 4f39b005a7 (submit/cleanup-vidmode-dispatch) Xext: vidmode: simplify reply struct initialization
Coherently moving all reply struct decls and assignments into static
initialization right at declaration, just before it is getting byte-
swapped and sent out. Zero-assignments can be dropped here, since the
compiler automatically initializes all other fields to zero.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6c2fcf24a0 (submit/cleanup-vidmode-dispatch) Xext: vidmode: tidy up multi-version request control flow, part 3
Some requests using different structs dependending on which protocol version
(v1 vs. v2) had been selected. That's is handled by coverting v1 structs into v2,
before proceeding with the actual handling.

The code flow of this is very complex and hard to understand. Cleaning this up
in several smaller steps, that are easier to digest.

This part moves the request payload structs (or pointers to them) into the
per-version branches. Within each branch following our usual scheme for
extension request handlers (eg. using the REQUEST*() macros and having a
pointer named `stuff` to the current request struct)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 0baa232235 (submit/cleanup-vidmode-dispatch) Xext: vidmode: tidy up multi-version request control flow, part 2
Some requests using different structs dependending on which protocol version
(v1 vs. v2) had been selected. That's is handled by coverting v1 structs into v2,
before proceeding with the actual handling.

The code flow of this is very complex and hard to understand. Cleaning this up
in several smaller steps, that are easier to digest.

This part is splitting the huge request handlers into upper and lower half,
where the upper is doing the version check and converting v1 requests into v2,
while the lower one is doing the actual request processing, operating on the
struct pointer passed in from the upper one, instead of the client struct's
request buffer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 4da568c469 (submit/cleanup-vidmode-dispatch) Xext: vidmode: tidy up multi-version request control flow, part 1
Some requests using different structs dependending on which protocol version
(v1 vs. v2) had been selected. That's is handled by coverting v1 structs into v2,
before proceeding with the actual handling.

The code flow of this is very complex and hard to understand. Cleaning this up
in several smaller steps, that are easier to digest.

This moving the request size check into the if-version-X branches, to make it
some bit easier to undertand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 29dc21a93e (submit/cleanup-vidmode-dispatch) Xext: vidmode: simplify dispatcher
These dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 9e29d9fe4f (submit/cleanup-xf86bigfont) Xext: xf86bigfont: drop unncessary zero assignments
When using static struct initialization, fields not explicitly
stated are automatically zero.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 5b4485a90d (cleanup/xext-xres) Xext: xres: ProcXResQueryClientIds() collect reply in one stack buffer
In order to allow simplifying the reply send path, collect the reply
fragments into one buffer, instead of arbitrary number of WriteToClient()
calls. This also makes it much easier for potentially new purely packet-based
transports which (eg. binder) that would need their own stream parsing logic.

This xres function is an exceptionally hard case, since payload is constructed
step by step, and it's size only known when finished. The current way of the
fragment handling still has lots of room for improvement (eg. using very small
number of allocations), but leaving this for later exercise.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 6107438647 (cleanup/xext-xres) Xext: xres: ProcXResQueryClientResources() simplify payload write out
Collect the few bits in a local array, so one WriteToClient() call is
sufficient. That's also easing further simplifications in upcoming commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 041da82154 (cleanup/xext-xres) Xext: xres: ProcXResQueryClients() simplify payload write out
Collect the few bits in a local array, so one WriteToClient() call is
sufficient. That's also easing further simplifications in upcoming commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 757a729ad1 (cleanup/xext-xres) Xext: xres: sort includes
Bring #include's into some logical order.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:05 +02:00
Enrico Weigelt, metux IT consult 574b486872 (cleanup/xext-xres) Xext: xres: use static initialization
* use static initialization where applicable
* drop unneeded setting of zero values

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:25:04 +02:00
Enrico Weigelt, metux IT consult c6408565b9 (submit/cleanup-xfixes) xfixes: use stack allocation and static init for reply structs
Canonicalize all reply structures onto stack allocation and static
initialization, like already done in most other extension. So make
the code easier to understand and allow further simplifications by
subsequent commits. Also gaining a little bit efficiency by skipping
some heap allocations.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult b8ce247d5d (submit/cleanup-xfixes) xfixes: simplify dispatcher
The dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

It's also much cleaner to use the defines from proto headers instead of
raw numbers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult c530d6fb63 (submit/cleanup-xfixes) xfixes: untwist Xinerama handling
The current way of switching between Xinerama and single-screen handlers
is quite complicated and needs call vector tables that are changed on
the fly, which in turn makes dispatching more complicated.

Reworking this into a simple and straight code flow, where individual request
procs just look at a flag to decide whether to call the Xinerama or single
screen version.

This isn't just much easier to understand (and debug), but also removes the need
or the call vectors, thus allowing further simplification of the dispatcher.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 0e7c45d8d4 (submit/recv-fds) os: read file descriptors into client struct at once
Instead of having the request handler ask for fd's one by one, just read them
all into a little array in ClientRec struct. And also automatically clean up
after request had been handled.

Request handlers need to set the entries to -1 if they shouldn't be closed
automatically.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 905ac4d3b2 (!1632) xkb: ProcXkbGetKbdByName(): collect sub-replies in buffer and write at once
Instead of dozens of little WriteToClient() calls, collect the sub-replies in
a buffer and send the whole reply out at once. This also allows more upcoming
simplifications in the send path.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 7982f4c719 (!1632) xkb: split XkbSendGeometry()
This function is a funny beast: it assembles and writes out an xkbGetGeometryReply,
called in two different cases, ProcXkbGetGeometry() as well as ProcXkbGetKbdByName().
In the latter case the whole reply is contained in another one. That's the reason
why it's payload size is computed separately - the caller must know that in order
to set up the container's reply size correctly.

As preparation for upcoming simplifications of the reply send path, splitting off
this function into pieces: XkbAssembleGeometry() just assembles the reply payload,
while it's callers now responsible for preparing the request header and writing
out both pieces.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult f0278176f5 (!1632) xkb: split XkbSendIndicatorMap()
This function is a funny beast: it assembles and writes out an xkbGetIndicatorMapReply,
called in two different cases, ProcXkbGetIndicatorMap() as well as ProcXkbGetKbdByName().
In the latter case the whole reply is contained in another one. That's the reason
why it's payload size is computed separately - the caller must know that in order
to set up the container's reply size correctly.

As preparation for upcoming simplifications of the reply send path, splitting off
this function into pieces: XkbAssembleIndicatorMap() just assembles the reply payload,
while it's callers now responsible for preparing the request header and writing
out both pieces.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 875f684552 (!1632) xkb: split XkbSendCompatMap()
This function is a funny beast: it assembles and writes out an xkbGetCompatMapReply,
called in two different cases, ProcXkbGetCompatMap() as well as ProcXkbGetKbdByName().
In the latter case the whole reply is contained in another one. That's the reason
why it's payload size is computed separately - the caller must know that in order
to set up the container's reply size correctly.

As preparation for upcoming simplifications of the reply send path, splitting off
this function into pieces: XkbAssembleCompatMap() just assembles the reply payload,
while it's callers now responsible for preparing the request header and writing
out both pieces.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 80b72910b8 (!1632) xkb: split XkbSendMap()
This function is a funny beast: it assembles and writes out an xkbGetMapReply,
called in two different cases, ProcXkbGetMap() as well as ProcXkbGetKbdByName().
In the latter case the whole reply is contained in another one. That's the reason
why it's payload size is computed separately - the caller must know that in order
to set up the container's reply size correctly.

As preparation for upcoming simplifications of the reply send path, splitting off
this function into pieces: XkbAssembleMap() just assembles the reply payload,
while it's callers now responsible for preparing the request header and writing
out both pieces.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult a813a00c89 (!1632) xkb: ProcXkbGetKbdByName(): static initialization of sub-reply structs
For easier reading, move th sub-reply structs down to where they're used
first and use static initialization for the common fields.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 3598a1c57c (!1632) xkb: ProcXkbGetKbdByName() simplify reply struct initialization
Move down the declaration of the reply struct, right before swapping and sending
and use static initialization.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 9c787e8781 (!1632) xkb: XkbSendGeometry(): pass in struct as value instead of pointer
The function doesn't need to pass anything back via this pointer, it's
the last consumer of this struct. Make understanding the code a bit easier
and clear the road for further simplifications by passing the struct as
value instead of pointer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 23f6e9ef8a (!1632) xkb: XkbSendNames(): move common code into a helper macro
A little bit of simplification by putting repeated statements into macro.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 76a58eb5fa (!1632) xkb: XkbSendNames(): pass in struct as value instead of pointer
The function doesn't need to pass anything back via this pointer, it's
the last consumer of this struct. Make understanding the code a bit easier
and clear the road for further simplifications by passing the struct as
value instead of pointer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult cbeeccedc0 (!1632) xkb: let SendDeviceLedFBs() fill buffer instead of writing directly
Make the code flow a bit easier to understand and allow further simplification
by now just having to write out one additional payload as one block.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult fbe85a576b (!1632) xkb: ProcXkbGetDeviceInfo(): consolidate buffers to reduce writes
Putting both payload pieces into one buffer, so it can be written out
with only one call.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult e415861cfd (!1632) xkb: CheckDeviceLedFBs(): untwist parameters
It's hard to see which fields of the xkbGetDeviceInfoReply struct it's
reading or writing, and that complicates further simplifications of the
caller. So instead let the caller pass in the relevant fields and do the
modifications on the reply structs on its own.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 55e5eb36ad (!1632) xkb: XkbSendIndicatorMap(): little simplification
A bit simplification in code flow.
The extra length check (did we write as much as intended?) isn't necessary,
since the buffer size is computed by the very same data before this
function is called.

Hint: the size computation must be done before calling this one, because
the reply might be encapsulated in another one (xkbGetKbdByName).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult abf1db322b (!1632) xkb: XkbSendIndicatorMap() pass in reply struct as value instead of pointer
It's not passing back any data via that pointer and actually the last
consumer of it. Changing it to value instead of pointer clears the
road for further simplifications by subsequent patches.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 1f806a6256 (!1632) xkb: XkbSendCompatMap(): little cleanup and simplification
Make it a bit simpler and easier to read.

calloc() and WriteToClient() can handle zero lengths very well.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 0802aecc1f (!1632) xkb: XkbSendCompatMap(): pass xkbGetCompatMapReply as value instead of pointer
It's not passing back any data via that pointer and actually the last
consumer of it. Changing it to value instead of pointer clears the
road for further simplifications by subsequent patches.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 41d6863370 (!1632) xkb: XkbSendMap(): some little variable decl cleanups
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 94b58409ff (!1632) xkb: XkbSendMap() pass in reply struct as value instead of pointer
It's not passing back any data via that pointer and actually the last
consumer of it. Changing it to value instead of pointer clears the
road for further simplifications by subsequent patches.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 143faef683 (!1632) xkb: XkbWriteVirtualModMap(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 9070f6a543 (!1632) xkb: XkbWriteModifierMap(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 9a85c8dd21 (!1632) xkb: XkbWriteExplicit(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult cffb71b947 (!1632) xkb: XkbWriteKeyBehaviors(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 0ed09b7093 (!1632) xkb: XkbWriteKeyActions(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult efc149c763 (!1632) xkb: XkbWriteKeyTypes(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 2557593ab7 (!1632) xkb: XkbWriteKeySyms(): only pass in the needed data
We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult c9c5477aab (!1632) xkb: SProcXkbSelectEvents(): simplify swapping
The swapping logic isn't entirely trivial to understand and can be
simplified.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 3d4d655f2b (!1632) xkb: simplify reply struct initialization
Use static initializaton as much as possible and drop unnecessary
or duplicate zero assignments.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 3dd5b15421 (submit/cleanup-composite) composite: simplify dispatcher
The dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

It's also much cleaner to use the defines from proto headers instead of
raw numbers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 28316162ef (submit/cleanup-composite) composite: untwist Xinerama handling
The current way of switching between Xinerama and single-screen handlers
is quite complicated and needs call vector tables that are changed on
the fly, which in turn makes dispatching more complicated.

Reworking this into a simple and straight code flow, where individual request
procs just look at a flag to decide whether to call the Xinerama or single
screen version.

This isn't just much easier to understand (and debug), but also removes the need
or the call vectors, thus allowing further simplification of the dispatcher.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 8b64458aa7 (!1794) 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>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 5c68141260 (!1794) 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>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 41da339328 (!1796) dri3: simplify dispatcher
The dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

It's also much cleaner to use the defines from proto headers instead of
raw numbers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult 73a8b21464 (!1796) dri3: consolidate reply buffers
Allocate reply buffers on stack and put multiple fragments into one buffer,
in order to make it easier doing write out by generic macros, in subsequent
commits.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult e32927e8cf (!1796) dri3: use static reply struct init on declaration
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>
2025-06-26 11:21:20 +02:00
Enrico Weigelt, metux IT consult e996fd6a95 (1626) Xext: xvmc: simplify reply struct initialization
* use static initialization where possible
* put the lists into one one block, so they can be written in one pass
* simplify size computations

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:19 +02:00
Enrico Weigelt, metux IT consult 254f467939 (1626) Xext: xvmc: simplify dispatcher
The dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-26 11:21:19 +02:00
140 changed files with 4536 additions and 9193 deletions

View File

@ -33,6 +33,7 @@ from The Open Group.
#include <X11/extensions/bigreqsproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "misc.h"
#include "os.h"
@ -44,25 +45,19 @@ from The Open Group.
static int
ProcBigReqDispatch(ClientPtr client)
{
REQUEST(xBigReqEnableReq);
xBigReqEnableReply rep;
REQUEST_HEAD_STRUCT(xBigReqEnableReq);
if (stuff->brReqType != X_BigReqEnable)
return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq);
client->big_requests = TRUE;
rep = (xBigReqEnableReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xBigReqEnableReply rep = {
.max_request_size = maxBigRequestSize
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.max_request_size);
}
WriteToClient(client, sizeof(xBigReqEnableReply), &rep);
return Success;
REPLY_FIELD_CARD32(max_request_size);
REPLY_SEND_RET_SUCCESS();
}
void

View File

@ -30,7 +30,9 @@ Equipment Corporation.
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/extensions/dpmsproto.h>
#include "dix/request_priv.h"
#include "os/screensaver.h"
#include "Xext/geext_priv.h"
@ -39,7 +41,6 @@ Equipment Corporation.
#include "dixstruct.h"
#include "extnsionst.h"
#include "opaque.h"
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
#include "extinit_priv.h"
#include "scrnintstr.h"
@ -124,12 +125,13 @@ SDPMSInfoNotifyEvent(xGenericEvent * from,
static int
ProcDPMSSelectInput(register ClientPtr client)
{
REQUEST(xDPMSSelectInputReq);
REQUEST_HEAD_STRUCT(xDPMSSelectInputReq);
REQUEST_FIELD_CARD32(eventMask);
DPMSEventPtr pEvent, pNewEvent, *pHead;
XID clientResource;
int i;
REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
i = dixLookupResourceByType((void **)&pHead, eventResource, DPMSEventType,
client,
DixWriteAccess);
@ -295,77 +297,56 @@ DPMSSet(ClientPtr client, int level)
static int
ProcDPMSGetVersion(ClientPtr client)
{
/* REQUEST(xDPMSGetVersionReq); */
REQUEST_HEAD_STRUCT(xDPMSGetVersionReq);
REQUEST_FIELD_CARD16(majorVersion);
REQUEST_FIELD_CARD16(minorVersion);
xDPMSGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_DPMS_MAJOR_VERSION,
.minorVersion = SERVER_DPMS_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xDPMSGetVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcDPMSCapable(ClientPtr client)
{
/* REQUEST(xDPMSCapableReq); */
REQUEST_HEAD_STRUCT(xDPMSCapableReq);
xDPMSCapableReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.capable = TRUE
};
REQUEST_SIZE_MATCH(xDPMSCapableReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xDPMSCapableReply), &rep);
return Success;
REPLY_SEND_RET_SUCCESS();
}
static int
ProcDPMSGetTimeouts(ClientPtr client)
{
/* REQUEST(xDPMSGetTimeoutsReq); */
REQUEST_HEAD_STRUCT(xDPMSGetTimeoutsReq);
xDPMSGetTimeoutsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
.off = DPMSOffTime / MILLI_PER_SECOND
};
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.standby);
swaps(&rep.suspend);
swaps(&rep.off);
}
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), &rep);
return Success;
REPLY_FIELD_CARD16(standby);
REPLY_FIELD_CARD16(suspend);
REPLY_FIELD_CARD16(off);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcDPMSSetTimeouts(ClientPtr client)
{
REQUEST(xDPMSSetTimeoutsReq);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
REQUEST_HEAD_STRUCT(xDPMSSetTimeoutsReq);
REQUEST_FIELD_CARD16(standby);
REQUEST_FIELD_CARD16(suspend);
REQUEST_FIELD_CARD16(off);
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) {
client->errorValue = stuff->off;
@ -387,9 +368,9 @@ ProcDPMSSetTimeouts(ClientPtr client)
static int
ProcDPMSEnable(ClientPtr client)
{
Bool was_enabled = DPMSEnabled;
REQUEST_HEAD_STRUCT(xDPMSEnableReq);
REQUEST_SIZE_MATCH(xDPMSEnableReq);
Bool was_enabled = DPMSEnabled;
DPMSEnabled = TRUE;
if (!was_enabled) {
@ -403,12 +384,10 @@ ProcDPMSEnable(ClientPtr client)
static int
ProcDPMSDisable(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xDPMSDisableReq);
Bool was_enabled = DPMSEnabled;
/* REQUEST(xDPMSDisableReq); */
REQUEST_SIZE_MATCH(xDPMSDisableReq);
DPMSSet(client, DPMSModeOn);
DPMSEnabled = FALSE;
@ -421,9 +400,8 @@ ProcDPMSDisable(ClientPtr client)
static int
ProcDPMSForceLevel(ClientPtr client)
{
REQUEST(xDPMSForceLevelReq);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
REQUEST_HEAD_STRUCT(xDPMSForceLevelReq);
REQUEST_FIELD_CARD16(level);
if (!DPMSEnabled)
return BadMatch;
@ -443,23 +421,15 @@ ProcDPMSForceLevel(ClientPtr client)
static int
ProcDPMSInfo(ClientPtr client)
{
/* REQUEST(xDPMSInfoReq); */
REQUEST_HEAD_STRUCT(xDPMSInfoReq);
xDPMSInfoReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.power_level = DPMSPowerLevel,
.state = DPMSEnabled
};
REQUEST_SIZE_MATCH(xDPMSInfoReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.power_level);
}
WriteToClient(client, sizeof(xDPMSInfoReply), &rep);
return Success;
REPLY_FIELD_CARD16(power_level);
REPLY_SEND_RET_SUCCESS();
}
static int
@ -491,78 +461,6 @@ ProcDPMSDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcDPMSGetVersion(ClientPtr client)
{
REQUEST(xDPMSGetVersionReq);
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcDPMSGetVersion(client);
}
static int _X_COLD
SProcDPMSSetTimeouts(ClientPtr client)
{
REQUEST(xDPMSSetTimeoutsReq);
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
swaps(&stuff->standby);
swaps(&stuff->suspend);
swaps(&stuff->off);
return ProcDPMSSetTimeouts(client);
}
static int _X_COLD
SProcDPMSForceLevel(ClientPtr client)
{
REQUEST(xDPMSForceLevelReq);
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
swaps(&stuff->level);
return ProcDPMSForceLevel(client);
}
static int _X_COLD
SProcDPMSSelectInput(ClientPtr client)
{
REQUEST(xDPMSSelectInputReq);
REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
swapl(&stuff->eventMask);
return ProcDPMSSelectInput(client);
}
static int _X_COLD
SProcDPMSDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_DPMSGetVersion:
return SProcDPMSGetVersion(client);
case X_DPMSCapable:
return ProcDPMSCapable(client);
case X_DPMSGetTimeouts:
return ProcDPMSGetTimeouts(client);
case X_DPMSSetTimeouts:
return SProcDPMSSetTimeouts(client);
case X_DPMSEnable:
return ProcDPMSEnable(client);
case X_DPMSDisable:
return ProcDPMSDisable(client);
case X_DPMSForceLevel:
return SProcDPMSForceLevel(client);
case X_DPMSInfo:
return ProcDPMSInfo(client);
case X_DPMSSelectInput:
return SProcDPMSSelectInput(client);
default:
return BadRequest;
}
}
static void
DPMSCloseDownExtension(ExtensionEntry *e)
{
@ -592,7 +490,7 @@ DPMSExtensionInit(void)
if (DPMSEnabled && ClientType && DPMSEventType &&
(extEntry = AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
ProcDPMSDispatch, ProcDPMSDispatch,
DPMSCloseDownExtension, StandardMinorOpcode))) {
DPMSReqCode = extEntry->base;
GERegisterExtension(DPMSReqCode, SDPMSInfoNotifyEvent);

View File

@ -28,6 +28,7 @@
#include <X11/extensions/ge.h>
#include <X11/extensions/geproto.h>
#include "dix/request_priv.h"
#include "Xext/geext_priv.h"
#include "windowstr.h"
@ -67,20 +68,14 @@ static void SGEGenericEvent(xEvent *from, xEvent *to);
static int
ProcGEQueryVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xGEQueryVersionReq);
REQUEST_FIELD_CARD16(majorVersion);
REQUEST_FIELD_CARD16(minorVersion);
GEClientInfoPtr pGEClient = GEGetClient(client);
xGEQueryVersionReply rep;
REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
rep = (xGEQueryVersionReply) {
.repType = X_Reply,
xGEQueryVersionReply rep = {
.RepType = X_GEQueryVersion,
.sequenceNumber = client->sequence,
.length = 0,
/* return the supported version by the server */
.majorVersion = SERVER_GE_MAJOR_VERSION,
.minorVersion = SERVER_GE_MINOR_VERSION
};
@ -89,28 +84,9 @@ ProcGEQueryVersion(ClientPtr client)
pGEClient->major_version = stuff->majorVersion;
pGEClient->minor_version = stuff->minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xGEQueryVersionReply), &rep);
return Success;
}
/************************************************************/
/* swapped request handlers */
/************************************************************/
static int _X_COLD
SProcGEQueryVersion(ClientPtr client)
{
REQUEST(xGEQueryVersionReq);
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcGEQueryVersion(client);
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
/************************************************************/
@ -131,21 +107,6 @@ ProcGEDispatch(ClientPtr client)
}
}
/* dispatch swapped requests */
static int _X_COLD
SProcGEDispatch(ClientPtr client)
{
REQUEST(xReq);
swaps(&stuff->length);
switch (stuff->data) {
case X_GEQueryVersion:
return SProcGEQueryVersion(client);
default:
return BadRequest;
}
}
/* Reset extension. Called on server shutdown. */
static void
GEResetProc(ExtensionEntry * extEntry)
@ -186,7 +147,7 @@ GEExtensionInit(void)
(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n");
if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, SProcGEDispatch,
if (!AddExtension(GE_NAME, 0, GENumberErrors, ProcGEDispatch, ProcGEDispatch,
GEResetProc, StandardMinorOpcode))
FatalError("GEInit: AddExtensions failed.\n");

View File

@ -32,6 +32,7 @@ Equipment Corporation.
#include <X11/extensions/panoramiXproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "dix/screen_hooks_priv.h"
#include "Xext/panoramiX.h"
@ -457,7 +458,8 @@ PanoramiXExtensionInit(void)
while (panoramiXGeneration != serverGeneration) {
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPanoramiXDispatch,
SProcPanoramiXDispatch, PanoramiXResetProc,
ProcPanoramiXDispatch,
PanoramiXResetProc,
StandardMinorOpcode);
if (!extEntry)
break;
@ -898,94 +900,70 @@ PanoramiXResetProc(ExtensionEntry * extEntry)
int
ProcPanoramiXQueryVersion(ClientPtr client)
{
/* REQUEST(xPanoramiXQueryVersionReq); */
REQUEST_HEAD_STRUCT(xPanoramiXQueryVersionReq);
xPanoramiXQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION,
.minorVersion = SERVER_PANORAMIX_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
int
ProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
REQUEST_HEAD_STRUCT(xPanoramiXGetStateReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xPanoramiXGetStateReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetStateReply) {
.type = X_Reply,
xPanoramiXGetStateReply rep = {
.state = !noPanoramiXExtension,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), &rep);
return Success;
REPLY_FIELD_CARD32(window);
REPLY_SEND_RET_SUCCESS();
}
int
ProcPanoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
REQUEST_HEAD_STRUCT(xPanoramiXGetScreenCountReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xPanoramiXGetScreenCountReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetScreenCountReply) {
.type = X_Reply,
xPanoramiXGetScreenCountReply rep = {
.ScreenCount = PanoramiXNumScreens,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), &rep);
return Success;
REPLY_FIELD_CARD32(window);
REPLY_SEND_RET_SUCCESS();
}
int
ProcPanoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
WindowPtr pWin;
xPanoramiXGetScreenSizeReply rep;
int rc;
REQUEST_HEAD_STRUCT(xPanoramiXGetScreenSizeReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD32(screen);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
WindowPtr pWin;
int rc;
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
@ -994,40 +972,27 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
if (rc != Success)
return rc;
rep = (xPanoramiXGetScreenSizeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
/* screen dimensions */
xPanoramiXGetScreenSizeReply rep = {
/* screen dimensions */
.width = screenInfo.screens[stuff->screen]->width,
.height = screenInfo.screens[stuff->screen]->height,
.window = stuff->window,
.screen = stuff->screen
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.width);
swapl(&rep.height);
swapl(&rep.window);
swapl(&rep.screen);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), &rep);
return Success;
REPLY_FIELD_CARD32(width);
REPLY_FIELD_CARD32(height);
REPLY_FIELD_CARD32(window);
REPLY_FIELD_CARD32(screen);
REPLY_SEND_RET_SUCCESS();
}
int
ProcXineramaIsActive(ClientPtr client)
{
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
REQUEST_HEAD_STRUCT(xXineramaIsActiveReq);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXineramaIsActiveReply rep = {
#if 1
/* The following hack fools clients into thinking that Xinerama
* is disabled even though it is not. */
@ -1036,56 +1001,38 @@ ProcXineramaIsActive(ClientPtr client)
.state = !noPanoramiXExtension;
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.state);
}
WriteToClient(client, sizeof(xXineramaIsActiveReply), &rep);
return Success;
REPLY_FIELD_CARD32(state);
REPLY_SEND_RET_SUCCESS();
}
int
ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
REQUEST_HEAD_STRUCT(xXineramaQueryScreensReq);
CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
xXineramaQueryScreensReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(number * sz_XineramaScreenInfo),
.number = number
};
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.number);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
xXineramaScreenInfo scratch[number]; // upper bound limited, number of screens
if (!noPanoramiXExtension) {
xXineramaScreenInfo scratch;
int i;
FOR_NSCREENS_BACKWARD(i) {
scratch.x_org = screenInfo.screens[i]->x;
scratch.y_org = screenInfo.screens[i]->y;
scratch.width = screenInfo.screens[i]->width;
scratch.height = screenInfo.screens[i]->height;
if (client->swapped) {
swaps(&scratch.x_org);
swaps(&scratch.y_org);
swaps(&scratch.width);
swaps(&scratch.height);
}
WriteToClient(client, sz_XineramaScreenInfo, &scratch);
scratch[i].x_org = screenInfo.screens[i]->x;
scratch[i].y_org = screenInfo.screens[i]->y;
scratch[i].width = screenInfo.screens[i]->width;
scratch[i].height = screenInfo.screens[i]->height;
CLIENT_STRUCT_CARD16_4(&scratch[i], x_org, y_org, width, height);
}
}
REPLY_FIELD_CARD32(number);
REPLY_SEND_EXTRA(scratch, sizeof(scratch));
return Success;
}

View File

@ -1,97 +0,0 @@
/*****************************************************************
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Digital Equipment Corporation
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Digital
Equipment Corporation.
******************************************************************/
#include <dix-config.h>
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/extensions/panoramiXproto.h>
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h"
#include "cursor.h"
#include "cursorstr.h"
#include "extnsionst.h"
#include "dixstruct.h"
#include "gc.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "window.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "globals.h"
#include "panoramiXh.h"
static int _X_COLD
SProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl(&stuff->window);
return ProcPanoramiXGetState(client);
}
static int _X_COLD
SProcPanoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl(&stuff->window);
return ProcPanoramiXGetScreenCount(client);
}
static int _X_COLD
SProcPanoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl(&stuff->window);
swapl(&stuff->screen);
return ProcPanoramiXGetScreenSize(client);
}
int _X_COLD
SProcPanoramiXDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
return SProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount:
return SProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return SProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive:
return ProcXineramaIsActive(client);
case X_XineramaQueryScreens:
return ProcXineramaQueryScreens(client);
}
return BadRequest;
}

View File

@ -65,8 +65,6 @@ PROC_EXTERN(ProcPanoramiXGetScreenSize);
PROC_EXTERN(ProcXineramaQueryScreens);
PROC_EXTERN(ProcXineramaIsActive);
extern int SProcPanoramiXDispatch(ClientPtr client);
extern int connBlockScreenStart;
extern xConnSetupPrefix connSetupPrefix;

View File

@ -1960,7 +1960,6 @@ PanoramiXGetImage(ClientPtr client)
DrawablePtr pDraw;
PanoramiXRes *draw;
Bool isRoot;
char *pBuf;
int i, x, y, w, h, format, rc;
Mask plane = 0, planemask;
int linesDone, nlines, linesPerBuf;
@ -2032,7 +2031,6 @@ PanoramiXGetImage(ClientPtr client)
IncludeInferiors);
}
if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(w, pDraw->depth);
length = widthBytesLine * h;
@ -2046,14 +2044,6 @@ PanoramiXGetImage(ClientPtr client)
}
xGetImageReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth,
.length = bytes_to_int32(length),
};
if (widthBytesLine == 0 || h == 0)
linesPerBuf = 0;
else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
@ -2063,15 +2053,9 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h)
linesPerBuf = h;
}
if (!(pBuf = calloc(linesPerBuf, widthBytesLine)))
return BadAlloc;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.visual);
}
WriteToClient(client, sizeof(rep), &rep);
char *payload = calloc(1, length);
char *walk = payload;
if (linesPerBuf == 0) {
/* nothing to do */
@ -2081,14 +2065,11 @@ PanoramiXGetImage(ClientPtr client)
while (h - linesDone > 0) {
nlines = min(linesPerBuf, h - linesDone);
if (pDraw->depth == 1)
memset(pBuf, 0, nlines * widthBytesLine);
XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
format, planemask, pBuf, widthBytesLine,
format, planemask, walk, widthBytesLine,
isRoot);
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
walk += nlines * widthBytesLine;
linesDone += nlines;
}
}
@ -2099,20 +2080,30 @@ PanoramiXGetImage(ClientPtr client)
while (h - linesDone > 0) {
nlines = min(linesPerBuf, h - linesDone);
memset(pBuf, 0, nlines * widthBytesLine);
XineramaGetImageData(drawables, x, y + linesDone, w,
nlines, format, plane, pBuf,
nlines, format, plane, walk,
widthBytesLine, isRoot);
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
walk += nlines * widthBytesLine;
linesDone += nlines;
}
}
}
}
free(pBuf);
xGetImageReply xgi = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth,
.length = bytes_to_int32(length),
};
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
if (length)
WriteToClient(client, length, payload);
return Success;
}

View File

@ -36,6 +36,7 @@ in this Software without prior written authorization from the X Consortium.
#include "dix/colormap_priv.h"
#include "dix/cursor_priv.h"
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "dix/window_priv.h"
#include "os/osdep.h"
#include "os/screensaver.h"
@ -591,35 +592,30 @@ ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
static int
ProcScreenSaverQueryVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xScreenSaverQueryVersionReq);
xScreenSaverQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.majorVersion = SERVER_SAVER_MAJOR_VERSION,
.minorVersion = SERVER_SAVER_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
REQUEST_HEAD_STRUCT(xScreenSaverQueryInfoReq);
REQUEST_FIELD_CARD32(drawable);
int rc;
ScreenSaverStuffPtr pSaver;
DrawablePtr pDraw;
CARD32 lastInput;
ScreenSaverScreenPrivatePtr pPriv;
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
@ -635,10 +631,11 @@ ProcScreenSaverQueryInfo(ClientPtr client)
lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
xScreenSaverQueryInfoReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.window = pSaver->wid
.window = pSaver->wid,
.idle = lastInput,
.eventMask = getEventMask(pDraw->pScreen, client),
};
if (screenIsSaved != SCREEN_SAVER_OFF) {
rep.state = ScreenSaverOn;
if (ScreenSaverTime)
@ -654,33 +651,30 @@ ProcScreenSaverQueryInfo(ClientPtr client)
rep.state = ScreenSaverDisabled;
}
}
rep.idle = lastInput;
rep.eventMask = getEventMask(pDraw->pScreen, client);
if (pPriv && pPriv->attr)
rep.kind = ScreenSaverExternal;
else if (ScreenSaverBlanking != DontPreferBlanking)
rep.kind = ScreenSaverBlanked;
else
rep.kind = ScreenSaverInternal;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.window);
swapl(&rep.tilOrSince);
swapl(&rep.idle);
swapl(&rep.eventMask);
}
WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), &rep);
return Success;
REPLY_FIELD_CARD32(window);
REPLY_FIELD_CARD32(tilOrSince);
REPLY_FIELD_CARD32(idle);
REPLY_FIELD_CARD32(eventMask);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcScreenSaverSelectInput(ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
REQUEST_HEAD_STRUCT(xScreenSaverSelectInputReq);
REQUEST_FIELD_CARD32(drawable);
REQUEST_FIELD_CARD32(eventMask);
DrawablePtr pDraw;
int rc;
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
@ -1058,8 +1052,16 @@ ScreenSaverUnsetAttributes(ClientPtr client, Drawable drawable)
static int
ProcScreenSaverSetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverSetAttributesReq);
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
REQUEST_HEAD_AT_LEAST(xScreenSaverSetAttributesReq);
REQUEST_FIELD_CARD32(drawable);
REQUEST_FIELD_CARD16(x);
REQUEST_FIELD_CARD16(y);
REQUEST_FIELD_CARD16(width);
REQUEST_FIELD_CARD16(height);
REQUEST_FIELD_CARD16(borderWidth);
REQUEST_FIELD_CARD32(visualID);
REQUEST_FIELD_CARD32(mask);
REQUEST_REST_CARD32();
#ifdef XINERAMA
if (!noPanoramiXExtension) {
@ -1145,15 +1147,14 @@ ProcScreenSaverSetAttributes(ClientPtr client)
static int
ProcScreenSaverUnsetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverUnsetAttributesReq);
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
REQUEST_HEAD_STRUCT(xScreenSaverUnsetAttributesReq);
REQUEST_FIELD_CARD32(drawable);
#ifdef XINERAMA
if (!noPanoramiXExtension) {
PanoramiXRes *draw;
int rc, i;
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success)
@ -1162,8 +1163,6 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
for (i = PanoramiXNumScreens - 1; i > 0; i--) {
ScreenSaverUnsetAttributes(client, draw->info[i].id);
}
stuff->drawable = draw->info[0].id;
}
#endif /* XINERAMA */
@ -1173,12 +1172,11 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
static int
ProcScreenSaverSuspend(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xScreenSaverSuspendReq);
REQUEST_FIELD_CARD32(suspend);
ScreenSaverSuspensionPtr *prev, this;
BOOL suspend;
REQUEST(xScreenSaverSuspendReq);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
/*
* Old versions of XCB encode suspend as 1 byte followed by three
* pad bytes (which are always cleared), instead of a 4 byte
@ -1257,82 +1255,6 @@ ProcScreenSaverDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
swapl(&stuff->drawable);
return ProcScreenSaverQueryInfo(client);
}
static int _X_COLD
SProcScreenSaverSelectInput(ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
swapl(&stuff->drawable);
swapl(&stuff->eventMask);
return ProcScreenSaverSelectInput(client);
}
static int _X_COLD
SProcScreenSaverSetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverSetAttributesReq);
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
swapl(&stuff->drawable);
swaps(&stuff->x);
swaps(&stuff->y);
swaps(&stuff->width);
swaps(&stuff->height);
swaps(&stuff->borderWidth);
swapl(&stuff->visualID);
swapl(&stuff->mask);
SwapRestL(stuff);
return ProcScreenSaverSetAttributes(client);
}
static int _X_COLD
SProcScreenSaverUnsetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverUnsetAttributesReq);
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
swapl(&stuff->drawable);
return ProcScreenSaverUnsetAttributes(client);
}
static int _X_COLD
SProcScreenSaverSuspend(ClientPtr client)
{
REQUEST(xScreenSaverSuspendReq);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
swapl(&stuff->suspend);
return ProcScreenSaverSuspend(client);
}
static int _X_COLD
SProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_ScreenSaverQueryVersion:
return ProcScreenSaverQueryVersion(client);
case X_ScreenSaverQueryInfo:
return SProcScreenSaverQueryInfo(client);
case X_ScreenSaverSelectInput:
return SProcScreenSaverSelectInput(client);
case X_ScreenSaverSetAttributes:
return SProcScreenSaverSetAttributes(client);
case X_ScreenSaverUnsetAttributes:
return SProcScreenSaverUnsetAttributes(client);
case X_ScreenSaverSuspend:
return SProcScreenSaverSuspend(client);
default:
return BadRequest;
}
}
void
ScreenSaverExtensionInit(void)
{
@ -1354,7 +1276,7 @@ ScreenSaverExtensionInit(void)
if (AttrType && SaverEventType && SuspendType &&
(extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0,
ProcScreenSaverDispatch,
SProcScreenSaverDispatch, NULL,
ProcScreenSaverDispatch, NULL,
StandardMinorOpcode))) {
ScreenSaverEventBase = extEntry->eventBase;
EventSwapVector[ScreenSaverEventBase] =

View File

@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include "dix/dix_priv.h"
#include "dix/registry_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "include/extinit_priv.h"
#include "os/audit.h"
@ -348,25 +349,19 @@ SecurityStartAuthorizationTimer(SecurityAuthorizationPtr pAuth)
static int
ProcSecurityQueryVersion(ClientPtr client)
{
/* REQUEST(xSecurityQueryVersionReq); */
REQUEST_HEAD_STRUCT(xSecurityQueryVersionReq);
REQUEST_FIELD_CARD16(majorVersion);
REQUEST_FIELD_CARD16(minorVersion);
xSecurityQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SECURITY_MAJOR_VERSION,
.minorVersion = SERVER_SECURITY_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, SIZEOF(xSecurityQueryVersionReply), &rep);
return Success;
} /* ProcSecurityQueryVersion */
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
@ -403,16 +398,32 @@ SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth,
static int
ProcSecurityGenerateAuthorization(ClientPtr client)
{
REQUEST(xSecurityGenerateAuthorizationReq);
REQUEST_HEAD_AT_LEAST(xSecurityGenerateAuthorizationReq);
REQUEST_FIELD_CARD16(nbytesAuthProto);
REQUEST_FIELD_CARD16(nbytesAuthData);
REQUEST_FIELD_CARD32(valueMask);
int values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
bytes_to_int32(stuff->nbytesAuthData);
if (values_offset > stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq))
return BadLength;
CARD32 *values = (CARD32 *) (&stuff[1]) + values_offset;
if (client->swapped) {
unsigned long nvalues;
nvalues = (((CARD32 *) stuff) + stuff->length) - values;
SwapLongs(values, nvalues);
}
int len; /* request length in CARD32s */
Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
int err; /* error to return from this function */
XID authId; /* authorization ID assigned by os layer */
xSecurityGenerateAuthorizationReply rep; /* reply struct */
unsigned int trustLevel; /* trust level of new auth */
XID group; /* group of new auth */
CARD32 timeout; /* timeout of new auth */
CARD32 *values; /* list of supplied attributes */
char *protoname; /* auth proto name sent in request */
char *protodata; /* auth proto data sent in request */
unsigned int authdata_len; /* # bytes of generated auth data */
@ -421,11 +432,8 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* check request length */
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
len = bytes_to_int32(SIZEOF(xSecurityGenerateAuthorizationReq));
len += bytes_to_int32(stuff->nbytesAuthProto);
len += bytes_to_int32(stuff->nbytesAuthData);
values = ((CARD32 *) stuff) + len;
len = bytes_to_int32(sizeof(xSecurityGenerateAuthorizationReq))
+ values_offset;
len += Ones(stuff->valueMask);
if (client->req_len != len)
return BadLength;
@ -536,31 +544,22 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
if (pAuth->timeout != 0)
SecurityStartAuthorizationTimer(pAuth);
/* tell client the auth id and data */
rep = (xSecurityGenerateAuthorizationReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(authdata_len),
.authId = authId,
.dataLength = authdata_len
};
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.authId);
swaps(&rep.dataLength);
}
WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply), &rep);
WriteToClient(client, authdata_len, pAuthdata);
SecurityAudit
("client %d generated authorization %lu trust %d timeout %lu group %lu events %lu\n",
client->index, (unsigned long)pAuth->id, pAuth->trustLevel, (unsigned long)pAuth->timeout,
(unsigned long)pAuth->group, (unsigned long)eventMask);
/* tell client the auth id and data */
xSecurityGenerateAuthorizationReply rep = {
.authId = authId,
.dataLength = authdata_len
};
REPLY_FIELD_CARD32(authId);
REPLY_FIELD_CARD16(dataLength);
REPLY_SEND_EXTRA(pAuthdata, authdata_len);
/* the request succeeded; don't call RemoveAuthorization or free pAuth */
return Success;
@ -576,12 +575,12 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
static int
ProcSecurityRevokeAuthorization(ClientPtr client)
{
REQUEST(xSecurityRevokeAuthorizationReq);
REQUEST_HEAD_STRUCT(xSecurityRevokeAuthorizationReq);
REQUEST_FIELD_CARD32(authId);
SecurityAuthorizationPtr pAuth;
int rc;
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
rc = dixLookupResourceByType((void **) &pAuth, stuff->authId,
SecurityAuthorizationResType, client,
DixDestroyAccess);
@ -609,64 +608,6 @@ ProcSecurityDispatch(ClientPtr client)
}
} /* ProcSecurityDispatch */
static int _X_COLD
SProcSecurityQueryVersion(ClientPtr client)
{
REQUEST(xSecurityQueryVersionReq);
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcSecurityQueryVersion(client);
} /* SProcSecurityQueryVersion */
static int _X_COLD
SProcSecurityGenerateAuthorization(ClientPtr client)
{
REQUEST(xSecurityGenerateAuthorizationReq);
CARD32 *values;
unsigned long nvalues;
int values_offset;
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
swaps(&stuff->nbytesAuthProto);
swaps(&stuff->nbytesAuthData);
swapl(&stuff->valueMask);
values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
bytes_to_int32(stuff->nbytesAuthData);
if (values_offset >
client->req_len - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq))
return BadLength;
values = (CARD32 *) (&stuff[1]) + values_offset;
nvalues = (((CARD32 *) stuff) + client->req_len) - values;
SwapLongs(values, nvalues);
return ProcSecurityGenerateAuthorization(client);
} /* SProcSecurityGenerateAuthorization */
static int _X_COLD
SProcSecurityRevokeAuthorization(ClientPtr client)
{
REQUEST(xSecurityRevokeAuthorizationReq);
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
swapl(&stuff->authId);
return ProcSecurityRevokeAuthorization(client);
} /* SProcSecurityRevokeAuthorization */
static int _X_COLD
SProcSecurityDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_SecurityQueryVersion:
return SProcSecurityQueryVersion(client);
case X_SecurityGenerateAuthorization:
return SProcSecurityGenerateAuthorization(client);
case X_SecurityRevokeAuthorization:
return SProcSecurityRevokeAuthorization(client);
default:
return BadRequest;
}
} /* SProcSecurityDispatch */
static void _X_COLD
SwapSecurityAuthorizationRevokedEvent(xSecurityAuthorizationRevokedEvent * from,
xSecurityAuthorizationRevokedEvent * to)
@ -1078,7 +1019,7 @@ SecurityExtensionInit(void)
/* Add extension to server */
extEntry = AddExtension(SECURITY_EXTENSION_NAME,
XSecurityNumberEvents, XSecurityNumberErrors,
ProcSecurityDispatch, SProcSecurityDispatch,
ProcSecurityDispatch, ProcSecurityDispatch,
SecurityResetProc, StandardMinorOpcode);
SecurityErrorBase = extEntry->errorBase;

View File

@ -33,6 +33,7 @@ in this Software without prior written authorization from The Open Group.
#include "dix/dix_priv.h"
#include "dix/gc_priv.h"
#include "dix/request_priv.h"
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
@ -204,24 +205,16 @@ CreateClipShape(WindowPtr pWin)
static int
ProcShapeQueryVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShapeQueryVersionReq);
xShapeQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SHAPE_MAJOR_VERSION,
.minorVersion = SERVER_SHAPE_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xShapeQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xShapeQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
@ -291,8 +284,11 @@ ShapeRectangles(ClientPtr client, xShapeRectanglesReq *stuff)
static int
ProcShapeRectangles(ClientPtr client)
{
REQUEST(xShapeRectanglesReq);
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
REQUEST_HEAD_AT_LEAST(xShapeRectanglesReq);
REQUEST_FIELD_CARD32(dest);
REQUEST_FIELD_CARD16(xOff);
REQUEST_FIELD_CARD16(yOff);
REQUEST_REST_CARD16();
#ifdef XINERAMA
if (noPanoramiXExtension)
@ -387,8 +383,11 @@ ShapeMask(ClientPtr client, xShapeMaskReq *stuff)
static int
ProcShapeMask(ClientPtr client)
{
REQUEST(xShapeMaskReq);
REQUEST_SIZE_MATCH(xShapeMaskReq);
REQUEST_HEAD_STRUCT(xShapeMaskReq);
REQUEST_FIELD_CARD32(dest);
REQUEST_FIELD_CARD16(xOff);
REQUEST_FIELD_CARD16(yOff);
REQUEST_FIELD_CARD32(src);
#ifdef XINERAMA
if (noPanoramiXExtension)
@ -513,8 +512,11 @@ ShapeCombine(ClientPtr client, xShapeCombineReq *stuff)
static int
ProcShapeCombine(ClientPtr client)
{
REQUEST(xShapeCombineReq);
REQUEST_AT_LEAST_SIZE(xShapeCombineReq);
REQUEST_HEAD_STRUCT(xShapeCombineReq);
REQUEST_FIELD_CARD32(dest);
REQUEST_FIELD_CARD16(xOff);
REQUEST_FIELD_CARD16(yOff);
REQUEST_FIELD_CARD32(src);
#ifdef XINERAMA
if (noPanoramiXExtension)
@ -582,8 +584,10 @@ ShapeOffset(ClientPtr client, xShapeOffsetReq *stuff)
static int
ProcShapeOffset(ClientPtr client)
{
REQUEST(xShapeOffsetReq);
REQUEST_AT_LEAST_SIZE(xShapeOffsetReq);
REQUEST_HEAD_AT_LEAST(xShapeOffsetReq);
REQUEST_FIELD_CARD32(dest);
REQUEST_FIELD_CARD16(yOff);
REQUEST_FIELD_CARD16(yOff);
#ifdef XINERAMA
PanoramiXRes *win;
@ -612,24 +616,23 @@ ProcShapeOffset(ClientPtr client)
static int
ProcShapeQueryExtents(ClientPtr client)
{
REQUEST(xShapeQueryExtentsReq);
REQUEST_HEAD_STRUCT(xShapeQueryExtentsReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xShapeQueryExtentsReply rep;
BoxRec extents, *pExtents;
int rc;
RegionPtr region;
REQUEST_SIZE_MATCH(xShapeQueryExtentsReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xShapeQueryExtentsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xShapeQueryExtentsReply rep = {
.boundingShaped = (wBoundingShape(pWin) != 0),
.clipShaped = (wClipShape(pWin) != 0)
};
if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = RegionExtents(region);
@ -660,20 +663,16 @@ ProcShapeQueryExtents(ClientPtr client)
rep.yClipShape = extents.y1;
rep.widthClipShape = extents.x2 - extents.x1;
rep.heightClipShape = extents.y2 - extents.y1;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.xBoundingShape);
swaps(&rep.yBoundingShape);
swaps(&rep.widthBoundingShape);
swaps(&rep.heightBoundingShape);
swaps(&rep.xClipShape);
swaps(&rep.yClipShape);
swaps(&rep.widthClipShape);
swaps(&rep.heightClipShape);
}
WriteToClient(client, sizeof(xShapeQueryExtentsReply), &rep);
return Success;
REPLY_FIELD_CARD16(xBoundingShape);
REPLY_FIELD_CARD16(yBoundingShape);
REPLY_FIELD_CARD16(widthBoundingShape);
REPLY_FIELD_CARD16(heightBoundingShape);
REPLY_FIELD_CARD16(xClipShape);
REPLY_FIELD_CARD16(yClipShape);
REPLY_FIELD_CARD16(widthClipShape);
REPLY_FIELD_CARD16(heightClipShape);
REPLY_SEND_RET_SUCCESS();
}
/*ARGSUSED*/ static int
@ -721,13 +720,14 @@ ShapeFreeEvents(void *data, XID id)
static int
ProcShapeSelectInput(ClientPtr client)
{
REQUEST(xShapeSelectInputReq);
REQUEST_HEAD_STRUCT(xShapeSelectInputReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
ShapeEventPtr pShapeEvent, pNewShapeEvent, *pHead;
XID clientResource;
int rc;
REQUEST_SIZE_MATCH(xShapeSelectInputReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success)
return rc;
@ -892,13 +892,13 @@ SendShapeNotify(WindowPtr pWin, int which)
static int
ProcShapeInputSelected(ClientPtr client)
{
REQUEST(xShapeInputSelectedReq);
REQUEST_HEAD_STRUCT(xShapeInputSelectedReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
ShapeEventPtr pShapeEvent, *pHead;
int enabled, rc;
xShapeInputSelectedReply rep;
REQUEST_SIZE_MATCH(xShapeInputSelectedReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -915,31 +915,25 @@ ProcShapeInputSelected(ClientPtr client)
}
}
}
rep = (xShapeInputSelectedReply) {
.type = X_Reply,
xShapeInputSelectedReply rep = {
.enabled = enabled,
.sequenceNumber = client->sequence,
.length = 0
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xShapeInputSelectedReply), &rep);
return Success;
REPLY_SEND_RET_SUCCESS();
}
static int
ProcShapeGetRectangles(ClientPtr client)
{
REQUEST(xShapeGetRectanglesReq);
REQUEST_HEAD_STRUCT(xShapeGetRectanglesReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xShapeGetRectanglesReply rep;
xRectangle *rects = NULL;
int nrects, i, rc;
RegionPtr region;
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -1000,21 +994,15 @@ ProcShapeGetRectangles(ClientPtr client)
}
}
}
rep = (xShapeGetRectanglesReply) {
.type = X_Reply,
xShapeGetRectanglesReply rep = {
.ordering = YXBanded,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(nrects * sizeof(xRectangle)),
.nrects = nrects
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.nrects);
SwapShorts((short *) rects, (unsigned long) nrects * 4);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, nrects * sizeof(xRectangle), rects);
REPLY_BUF_CARD16(rects, (unsigned long) nrects * 4);
REPLY_FIELD_CARD32(nrects);
REPLY_SEND_EXTRA(rects, nrects * sizeof(xRectangle));
free(rects);
return Success;
}
@ -1062,117 +1050,6 @@ SShapeNotifyEvent(xShapeNotifyEvent * from, xShapeNotifyEvent * to)
to->shaped = from->shaped;
}
static int _X_COLD
SProcShapeRectangles(ClientPtr client)
{
REQUEST(xShapeRectanglesReq);
REQUEST_AT_LEAST_SIZE(xShapeRectanglesReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
SwapRestS(stuff);
return ProcShapeRectangles(client);
}
static int _X_COLD
SProcShapeMask(ClientPtr client)
{
REQUEST(xShapeMaskReq);
REQUEST_SIZE_MATCH(xShapeMaskReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl(&stuff->src);
return ProcShapeMask(client);
}
static int _X_COLD
SProcShapeCombine(ClientPtr client)
{
REQUEST(xShapeCombineReq);
REQUEST_SIZE_MATCH(xShapeCombineReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl(&stuff->src);
return ProcShapeCombine(client);
}
static int _X_COLD
SProcShapeOffset(ClientPtr client)
{
REQUEST(xShapeOffsetReq);
REQUEST_SIZE_MATCH(xShapeOffsetReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
return ProcShapeOffset(client);
}
static int _X_COLD
SProcShapeQueryExtents(ClientPtr client)
{
REQUEST(xShapeQueryExtentsReq);
REQUEST_SIZE_MATCH(xShapeQueryExtentsReq);
swapl(&stuff->window);
return ProcShapeQueryExtents(client);
}
static int _X_COLD
SProcShapeSelectInput(ClientPtr client)
{
REQUEST(xShapeSelectInputReq);
REQUEST_SIZE_MATCH(xShapeSelectInputReq);
swapl(&stuff->window);
return ProcShapeSelectInput(client);
}
static int _X_COLD
SProcShapeInputSelected(ClientPtr client)
{
REQUEST(xShapeInputSelectedReq);
REQUEST_SIZE_MATCH(xShapeInputSelectedReq);
swapl(&stuff->window);
return ProcShapeInputSelected(client);
}
static int _X_COLD
SProcShapeGetRectangles(ClientPtr client)
{
REQUEST(xShapeGetRectanglesReq);
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
swapl(&stuff->window);
return ProcShapeGetRectangles(client);
}
static int _X_COLD
SProcShapeDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_ShapeQueryVersion:
return ProcShapeQueryVersion(client);
case X_ShapeRectangles:
return SProcShapeRectangles(client);
case X_ShapeMask:
return SProcShapeMask(client);
case X_ShapeCombine:
return SProcShapeCombine(client);
case X_ShapeOffset:
return SProcShapeOffset(client);
case X_ShapeQueryExtents:
return SProcShapeQueryExtents(client);
case X_ShapeSelectInput:
return SProcShapeSelectInput(client);
case X_ShapeInputSelected:
return SProcShapeInputSelected(client);
case X_ShapeGetRectangles:
return SProcShapeGetRectangles(client);
default:
return BadRequest;
}
}
void
ShapeExtensionInit(void)
{
@ -1182,7 +1059,7 @@ ShapeExtensionInit(void)
ShapeEventType = CreateNewResourceType(ShapeFreeEvents, "ShapeEvent");
if (ClientType && ShapeEventType &&
(extEntry = AddExtension(SHAPENAME, ShapeNumberEvents, 0,
ProcShapeDispatch, SProcShapeDispatch,
ProcShapeDispatch, ProcShapeDispatch,
NULL, StandardMinorOpcode))) {
ShapeEventBase = extEntry->eventBase;
EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent;

View File

@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xfuncproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "dix/screen_hooks_priv.h"
#include "os/auth.h"
#include "os/busfault.h"
@ -106,6 +107,8 @@ static void ShmResetProc(ExtensionEntry *extEntry);
static void SShmCompletionEvent(xShmCompletionEvent *from,
xShmCompletionEvent *to);
static int ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff);
static unsigned char ShmReqCode;
int ShmCompletionCode;
int BadShmSegCode;
@ -249,11 +252,10 @@ ShmRegisterFbFuncs(ScreenPtr pScreen)
static int
ProcShmQueryVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmQueryVersionReq);
xShmQueryVersionReply rep = {
.type = X_Reply,
.sharedPixmaps = sharedPixmaps,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SHM_MAJOR_VERSION,
.minorVersion = SERVER_SHM_MINOR_VERSION,
.uid = geteuid(),
@ -261,18 +263,11 @@ ProcShmQueryVersion(ClientPtr client)
.pixmapFormat = sharedPixmaps ? ZPixmap : 0
};
REQUEST_SIZE_MATCH(xShmQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swaps(&rep.uid);
swaps(&rep.gid);
}
WriteToClient(client, sizeof(xShmQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_FIELD_CARD16(uid);
REPLY_FIELD_CARD16(gid);
REPLY_SEND_RET_SUCCESS();
}
/*
@ -344,12 +339,16 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
static int
ProcShmAttach(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmAttachReq);
REQUEST_FIELD_CARD32(shmseg);
REQUEST_FIELD_CARD32(shmid);
if (!client->local)
return BadRequest;
SHMSTAT_TYPE buf;
ShmDescPtr shmdesc;
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly;
@ -429,11 +428,14 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */
static int
ProcShmDetach(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmDetachReq);
REQUEST_FIELD_CARD32(shmseg);
if (!client->local)
return BadRequest;
ShmDescPtr shmdesc;
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
FreeResource(stuff->shmseg, X11_RESTYPE_NONE);
return Success;
@ -490,16 +492,13 @@ doShmPutImage(DrawablePtr dst, GCPtr pGC,
}
static int
ProcShmPutImage(ClientPtr client)
ShmPutImage(ClientPtr client, xShmPutImageReq *stuff)
{
GCPtr pGC;
DrawablePtr pDraw;
long length;
ShmDescPtr shmdesc;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
@ -589,20 +588,16 @@ ProcShmPutImage(ClientPtr client)
}
static int
ProcShmGetImage(ClientPtr client)
ShmGetImage(ClientPtr client, xShmGetImageReq *stuff)
{
DrawablePtr pDraw;
long lenPer = 0, length;
Mask plane = 0;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
VisualID visual = None;
RegionPtr pVisibleRegion = NULL;
int rc;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
return BadValue;
@ -642,13 +637,6 @@ ProcShmGetImage(ClientPtr client)
return BadMatch;
visual = None;
}
xgi = (xShmGetImageReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.visual = visual,
.depth = pDraw->depth
};
if (stuff->format == ZPixmap) {
length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
}
@ -660,7 +648,6 @@ ProcShmGetImage(ClientPtr client)
}
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
xgi.size = length;
if (length == 0) {
/* nothing to do */
@ -677,7 +664,6 @@ ProcShmGetImage(ClientPtr client)
stuff->format, shmdesc->addr + stuff->offset);
}
else {
length = stuff->offset;
for (; plane; plane >>= 1) {
if (stuff->planeMask & plane) {
@ -696,27 +682,44 @@ ProcShmGetImage(ClientPtr client)
}
}
if (client->swapped) {
swaps(&xgi.sequenceNumber);
swapl(&xgi.length);
swapl(&xgi.visual);
swapl(&xgi.size);
}
WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
xShmGetImageReply rep = {
.visual = visual,
.depth = pDraw->depth,
.size = length,
};
return Success;
REPLY_FIELD_CARD32(visual);
REPLY_FIELD_CARD32(size);
REPLY_SEND_RET_SUCCESS();
}
#ifdef XINERAMA
static int
ProcPanoramiXShmPutImage(ClientPtr client)
ProcShmPutImage(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmPutImageReq);
REQUEST_FIELD_CARD32(drawable);
REQUEST_FIELD_CARD32(gc);
REQUEST_FIELD_CARD16(totalWidth);
REQUEST_FIELD_CARD16(totalHeight);
REQUEST_FIELD_CARD16(srcX);
REQUEST_FIELD_CARD16(srcY);
REQUEST_FIELD_CARD16(srcWidth);
REQUEST_FIELD_CARD16(srcHeight);
REQUEST_FIELD_CARD16(dstX);
REQUEST_FIELD_CARD16(dstY);
REQUEST_FIELD_CARD32(shmseg);
REQUEST_FIELD_CARD32(offset);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
int j, result, orig_x, orig_y;
PanoramiXRes *draw, *gc;
Bool sendEvent, isRoot;
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
if (noPanoramiXExtension)
return ShmPutImage(client, stuff);
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
@ -743,28 +746,43 @@ ProcPanoramiXShmPutImage(ClientPtr client)
stuff->dstX = orig_x - screenInfo.screens[j]->x;
stuff->dstY = orig_y - screenInfo.screens[j]->y;
}
result = ProcShmPutImage(client);
result = ShmPutImage(client, stuff);
if (result != Success)
break;
}
return result;
#else
return ShmPutImage(client, stuff);
#endif /* XINERAMA */
}
static int
ProcPanoramiXShmGetImage(ClientPtr client)
ProcShmGetImage(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmGetImageReq);
REQUEST_FIELD_CARD32(drawable);
REQUEST_FIELD_CARD16(x);
REQUEST_FIELD_CARD16(y);
REQUEST_FIELD_CARD16(width);
REQUEST_FIELD_CARD16(height);
REQUEST_FIELD_CARD32(planeMask);
REQUEST_FIELD_CARD32(shmseg);
REQUEST_FIELD_CARD32(offset);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
PanoramiXRes *draw;
DrawablePtr pDraw;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
int i, x, y, w, h, format, rc;
Mask plane = 0, planemask;
long lenPer = 0, length, widthBytesLine;
Bool isRoot;
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
if (noPanoramiXExtension)
return ShmGetImage(client, stuff);
if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
client->errorValue = stuff->format;
@ -777,7 +795,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
return (rc == BadValue) ? BadDrawable : rc;
if (draw->type == XRT_PIXMAP)
return ProcShmGetImage(client);
return ShmGetImage(client, stuff);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess);
if (rc != Success)
@ -848,16 +866,6 @@ ProcPanoramiXShmGetImage(ClientPtr client)
IncludeInferiors);
}
xgi = (xShmGetImageReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth
};
xgi.size = length;
if (length == 0) { /* nothing to do */
}
else if (format == ZPixmap) {
@ -879,33 +887,48 @@ ProcPanoramiXShmGetImage(ClientPtr client)
}
free(drawables);
if (client->swapped) {
swaps(&xgi.sequenceNumber);
swapl(&xgi.length);
swapl(&xgi.visual);
swapl(&xgi.size);
}
WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
xShmGetImageReply rep = {
.visual = wVisual(((WindowPtr) pDraw)),
.depth = pDraw->depth,
.size = length,
};
return Success;
REPLY_FIELD_CARD32(visual);
REPLY_FIELD_CARD32(size);
REPLY_SEND_RET_SUCCESS();
#else
return ShmGetImage(client, stuff);
#endif /* XINERAMA */
}
static int
ProcPanoramiXShmCreatePixmap(ClientPtr client)
ProcShmCreatePixmap(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmCreatePixmapReq);
REQUEST_FIELD_CARD32(pid);
REQUEST_FIELD_CARD32(drawable);
REQUEST_FIELD_CARD16(width);
REQUEST_FIELD_CARD16(height);
REQUEST_FIELD_CARD32(shmseg);
REQUEST_FIELD_CARD32(offset);
if (!client->local)
return BadRequest;
#ifdef XINERAMA
if (noPanoramiXExtension)
return ShmCreatePixmap(client, stuff);
ScreenPtr pScreen = NULL;
PixmapPtr pMap = NULL;
DrawablePtr pDraw;
DepthPtr pDepth;
int i, j, result, rc;
ShmDescPtr shmdesc;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth;
unsigned long size;
PanoramiXRes *newPix;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid;
if (!sharedPixmaps)
return BadImplementation;
@ -1001,8 +1024,10 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
AddResource(stuff->pid, XRT_PIXMAP, newPix);
return result;
}
#else
return ShmCreatePixmap(client, stuff);
#endif /* XINERAMA */
}
static PixmapPtr
fbShmCreatePixmap(ScreenPtr pScreen,
@ -1025,7 +1050,7 @@ fbShmCreatePixmap(ScreenPtr pScreen,
}
static int
ProcShmCreatePixmap(ClientPtr client)
ShmCreatePixmap(ClientPtr client, xShmCreatePixmapReq *stuff)
{
PixmapPtr pMap;
DrawablePtr pDraw;
@ -1033,12 +1058,9 @@ ProcShmCreatePixmap(ClientPtr client)
int i, rc;
ShmDescPtr shmdesc;
ShmScrPrivateRec *screen_priv;
REQUEST(xShmCreatePixmapReq);
unsigned int width, height, depth;
unsigned long size;
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
client->errorValue = stuff->pid;
if (!sharedPixmaps)
return BadImplementation;
@ -1120,19 +1142,24 @@ ShmBusfaultNotify(void *context)
static int
ProcShmAttachFd(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmAttachFdReq);
REQUEST_FIELD_CARD32(shmseg);
if (!client->local)
return BadRequest;
int fd;
ShmDescPtr shmdesc;
REQUEST(xShmAttachFdReq);
struct stat statb;
SetReqFds(client, 1);
REQUEST_SIZE_MATCH(xShmAttachFdReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly;
return BadValue;
}
fd = ReadFdFromClient(client);
fd = client->recv_fd_list[0];
client->recv_fd_list[0] = -1;
if (fd < 0)
return BadMatch;
@ -1235,17 +1262,16 @@ shm_tmpfile(void)
static int
ProcShmCreateSegment(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xShmCreateSegmentReq);
REQUEST_FIELD_CARD32(shmseg);
REQUEST_FIELD_CARD32(size);
if (!client->local)
return BadRequest;
int fd;
ShmDescPtr shmdesc;
REQUEST(xShmCreateSegmentReq);
xShmCreateSegmentReply rep = {
.type = X_Reply,
.nfd = 1,
.sequenceNumber = client->sequence,
.length = 0,
};
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
LEGAL_NEW_RESOURCE(stuff->shmseg, client);
if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
client->errorValue = stuff->readOnly;
@ -1300,8 +1326,12 @@ ProcShmCreateSegment(ClientPtr client)
close(fd);
return BadAlloc;
}
WriteToClient(client, sizeof (xShmCreateSegmentReply), &rep);
return Success;
xShmCreateSegmentReply rep = {
.nfd = 1,
};
REPLY_SEND_RET_SUCCESS();
}
#endif /* SHM_FD_PASSING */
@ -1310,34 +1340,18 @@ ProcShmDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data == X_ShmQueryVersion)
return ProcShmQueryVersion(client);
if (!client->local)
return BadRequest;
switch (stuff->data) {
case X_ShmQueryVersion:
return ProcShmQueryVersion(client);
case X_ShmAttach:
return ProcShmAttach(client);
case X_ShmDetach:
return ProcShmDetach(client);
case X_ShmPutImage:
#ifdef XINERAMA
if (!noPanoramiXExtension)
return ProcPanoramiXShmPutImage(client);
#endif /* XINERAMA */
return ProcShmPutImage(client);
case X_ShmGetImage:
#ifdef XINERAMA
if (!noPanoramiXExtension)
return ProcPanoramiXShmGetImage(client);
#endif /* XINERAMA */
return ProcShmGetImage(client);
case X_ShmCreatePixmap:
#ifdef XINERAMA
if (!noPanoramiXExtension)
return ProcPanoramiXShmCreatePixmap(client);
#endif /* XINERAMA */
return ProcShmCreatePixmap(client);
#ifdef SHM_FD_PASSING
case X_ShmAttachFd:
@ -1362,130 +1376,6 @@ SShmCompletionEvent(xShmCompletionEvent * from, xShmCompletionEvent * to)
cpswapl(from->offset, to->offset);
}
static int _X_COLD
SProcShmAttach(ClientPtr client)
{
REQUEST(xShmAttachReq);
REQUEST_SIZE_MATCH(xShmAttachReq);
swapl(&stuff->shmseg);
swapl(&stuff->shmid);
return ProcShmAttach(client);
}
static int _X_COLD
SProcShmDetach(ClientPtr client)
{
REQUEST(xShmDetachReq);
REQUEST_SIZE_MATCH(xShmDetachReq);
swapl(&stuff->shmseg);
return ProcShmDetach(client);
}
static int _X_COLD
SProcShmPutImage(ClientPtr client)
{
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
swapl(&stuff->drawable);
swapl(&stuff->gc);
swaps(&stuff->totalWidth);
swaps(&stuff->totalHeight);
swaps(&stuff->srcX);
swaps(&stuff->srcY);
swaps(&stuff->srcWidth);
swaps(&stuff->srcHeight);
swaps(&stuff->dstX);
swaps(&stuff->dstY);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmPutImage(client);
}
static int _X_COLD
SProcShmGetImage(ClientPtr client)
{
REQUEST(xShmGetImageReq);
REQUEST_SIZE_MATCH(xShmGetImageReq);
swapl(&stuff->drawable);
swaps(&stuff->x);
swaps(&stuff->y);
swaps(&stuff->width);
swaps(&stuff->height);
swapl(&stuff->planeMask);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmGetImage(client);
}
static int _X_COLD
SProcShmCreatePixmap(ClientPtr client)
{
REQUEST(xShmCreatePixmapReq);
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
swapl(&stuff->pid);
swapl(&stuff->drawable);
swaps(&stuff->width);
swaps(&stuff->height);
swapl(&stuff->shmseg);
swapl(&stuff->offset);
return ProcShmCreatePixmap(client);
}
#ifdef SHM_FD_PASSING
static int _X_COLD
SProcShmAttachFd(ClientPtr client)
{
REQUEST(xShmAttachFdReq);
SetReqFds(client, 1);
REQUEST_SIZE_MATCH(xShmAttachFdReq);
swapl(&stuff->shmseg);
return ProcShmAttachFd(client);
}
static int _X_COLD
SProcShmCreateSegment(ClientPtr client)
{
REQUEST(xShmCreateSegmentReq);
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
swapl(&stuff->shmseg);
swapl(&stuff->size);
return ProcShmCreateSegment(client);
}
#endif /* SHM_FD_PASSING */
static int _X_COLD
SProcShmDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data == X_ShmQueryVersion)
return ProcShmQueryVersion(client);
if (!client->local)
return BadRequest;
switch (stuff->data) {
case X_ShmAttach:
return SProcShmAttach(client);
case X_ShmDetach:
return SProcShmDetach(client);
case X_ShmPutImage:
return SProcShmPutImage(client);
case X_ShmGetImage:
return SProcShmGetImage(client);
case X_ShmCreatePixmap:
return SProcShmCreatePixmap(client);
#ifdef SHM_FD_PASSING
case X_ShmAttachFd:
return SProcShmAttachFd(client);
case X_ShmCreateSegment:
return SProcShmCreateSegment(client);
#endif
default:
return BadRequest;
}
}
static void ShmPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
{
ShmDetachSegment(
@ -1530,7 +1420,7 @@ ShmExtensionInit(void)
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
if (ShmSegType &&
(extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
ProcShmDispatch, SProcShmDispatch,
ProcShmDispatch, ProcShmDispatch,
ShmResetProc, StandardMinorOpcode))) {
ShmReqCode = (unsigned char) extEntry->base;
ShmCompletionCode = extEntry->eventBase;

View File

@ -59,6 +59,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include <X11/extensions/syncproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "os/bug_priv.h"
#include "os/osdep.h"
@ -1267,21 +1268,14 @@ FreeAlarmClient(void *value, XID id)
static int
ProcSyncInitialize(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xSyncInitializeReq);
xSyncInitializeReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_SYNC_MAJOR_VERSION,
.minorVersion = SERVER_SYNC_MINOR_VERSION,
};
REQUEST_SIZE_MATCH(xSyncInitializeReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(rep), &rep);
return Success;
REPLY_SEND_RET_SUCCESS();
}
/*
@ -1290,17 +1284,16 @@ ProcSyncInitialize(ClientPtr client)
static int
ProcSyncListSystemCounters(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xSyncListSystemCountersReq);
xSyncListSystemCountersReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.nCounters = 0,
};
SysCounterInfo *psci;
int len = 0;
xSyncSystemCounter *list = NULL, *walklist = NULL;
REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
xorg_list_for_each_entry(psci, &SysCounterList, entry) {
/* pad to 4 byte boundary */
len += pad_to_int32(sz_xSyncSystemCounter + strlen(psci->name));
@ -1313,13 +1306,7 @@ ProcSyncListSystemCounters(ClientPtr client)
return BadAlloc;
}
rep.length = bytes_to_int32(len);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.nCounters);
}
REPLY_FIELD_CARD32(nCounters);
xorg_list_for_each_entry(psci, &SysCounterList, entry) {
int namelen;
@ -1331,12 +1318,8 @@ ProcSyncListSystemCounters(ClientPtr client)
namelen = strlen(psci->name);
walklist->name_length = namelen;
if (client->swapped) {
swapl(&walklist->counter);
swapl(&walklist->resolution_hi);
swapl(&walklist->resolution_lo);
swaps(&walklist->name_length);
}
CLIENT_STRUCT_CARD16_1(walklist, name_length);
CLIENT_STRUCT_CARD32_3(walklist, counter, resolution_hi, resolution_lo);
pname_in_reply = ((char *) walklist) + sz_xSyncSystemCounter;
strncpy(pname_in_reply, psci->name, namelen);
@ -1345,12 +1328,7 @@ ProcSyncListSystemCounters(ClientPtr client)
namelen));
}
WriteToClient(client, sizeof(rep), &rep);
if (len) {
WriteToClient(client, len, list);
free(list);
}
REPLY_SEND_EXTRA(list, len);
return Success;
}
@ -1361,12 +1339,13 @@ ProcSyncListSystemCounters(ClientPtr client)
static int
ProcSyncSetPriority(ClientPtr client)
{
REQUEST(xSyncSetPriorityReq);
REQUEST_HEAD_STRUCT(xSyncSetPriorityReq);
REQUEST_FIELD_CARD32(id);
REQUEST_FIELD_CARD32(priority);
ClientPtr priorityclient;
int rc;
REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
if (stuff->id == None)
priorityclient = client;
else {
@ -1396,37 +1375,26 @@ ProcSyncSetPriority(ClientPtr client)
static int
ProcSyncGetPriority(ClientPtr client)
{
REQUEST(xSyncGetPriorityReq);
xSyncGetPriorityReply rep;
ClientPtr priorityclient;
int rc;
REQUEST_HEAD_STRUCT(xSyncGetPriorityReq);
REQUEST_FIELD_CARD32(id);
REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
ClientPtr priorityclient;
if (stuff->id == None)
priorityclient = client;
else {
rc = dixLookupResourceOwner(&priorityclient, stuff->id, client,
int rc = dixLookupResourceOwner(&priorityclient, stuff->id, client,
DixGetAttrAccess);
if (rc != Success)
return rc;
}
rep = (xSyncGetPriorityReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xSyncGetPriorityReply rep = {
.priority = priorityclient->priority
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.priority);
}
WriteToClient(client, sizeof(xSyncGetPriorityReply), &rep);
return Success;
REPLY_FIELD_CARD32(priority);
REPLY_SEND_RET_SUCCESS();
}
/*
@ -1435,10 +1403,12 @@ ProcSyncGetPriority(ClientPtr client)
static int
ProcSyncCreateCounter(ClientPtr client)
{
REQUEST(xSyncCreateCounterReq);
int64_t initial;
REQUEST_HEAD_STRUCT(xSyncCreateCounterReq);
REQUEST_FIELD_CARD32(cid);
REQUEST_FIELD_CARD32(initial_value_lo);
REQUEST_FIELD_CARD32(initial_value_hi);
REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
int64_t initial;
LEGAL_NEW_RESOURCE(stuff->cid, client);
@ -1456,13 +1426,15 @@ ProcSyncCreateCounter(ClientPtr client)
static int
ProcSyncSetCounter(ClientPtr client)
{
REQUEST(xSyncSetCounterReq);
REQUEST_HEAD_STRUCT(xSyncSetCounterReq);
REQUEST_FIELD_CARD32(cid);
REQUEST_FIELD_CARD32(value_lo);
REQUEST_FIELD_CARD32(value_hi);
SyncCounter *pCounter;
int64_t newvalue;
int rc;
REQUEST_SIZE_MATCH(xSyncSetCounterReq);
rc = dixLookupResourceByType((void **) &pCounter, stuff->cid, RTCounter,
client, DixWriteAccess);
if (rc != Success)
@ -1484,14 +1456,16 @@ ProcSyncSetCounter(ClientPtr client)
static int
ProcSyncChangeCounter(ClientPtr client)
{
REQUEST(xSyncChangeCounterReq);
REQUEST_HEAD_STRUCT(xSyncChangeCounterReq);
REQUEST_FIELD_CARD32(cid);
REQUEST_FIELD_CARD32(value_lo);
REQUEST_FIELD_CARD32(value_hi);
SyncCounter *pCounter;
int64_t newvalue;
Bool overflow;
int rc;
REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
rc = dixLookupResourceByType((void **) &pCounter, stuff->cid, RTCounter,
client, DixWriteAccess);
if (rc != Success)
@ -1519,12 +1493,12 @@ ProcSyncChangeCounter(ClientPtr client)
static int
ProcSyncDestroyCounter(ClientPtr client)
{
REQUEST(xSyncDestroyCounterReq);
REQUEST_HEAD_STRUCT(xSyncDestroyCounterReq);
REQUEST_FIELD_CARD32(counter);
SyncCounter *pCounter;
int rc;
REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
rc = dixLookupResourceByType((void **) &pCounter, stuff->counter,
RTCounter, client, DixDestroyAccess);
if (rc != Success)
@ -1600,7 +1574,9 @@ SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion * pAwaitUnion)
static int
ProcSyncAwait(ClientPtr client)
{
REQUEST(xSyncAwaitReq);
REQUEST_HEAD_AT_LEAST(xSyncAwaitReq);
REQUEST_REST_CARD32();
int len, items;
int i;
xSyncWaitCondition *pProtocolWaitConds;
@ -1608,8 +1584,6 @@ ProcSyncAwait(ClientPtr client)
SyncAwait *pAwait;
int status;
REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
len = client->req_len << 2;
len -= sz_xSyncAwaitReq;
items = len / sz_xSyncWaitCondition;
@ -1680,13 +1654,12 @@ ProcSyncAwait(ClientPtr client)
static int
ProcSyncQueryCounter(ClientPtr client)
{
REQUEST(xSyncQueryCounterReq);
xSyncQueryCounterReply rep;
REQUEST_HEAD_STRUCT(xSyncQueryCounterReq);
REQUEST_FIELD_CARD32(counter);
SyncCounter *pCounter;
int rc;
REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
rc = dixLookupResourceByType((void **) &pCounter, stuff->counter,
RTCounter, client, DixReadAccess);
if (rc != Success)
@ -1698,22 +1671,14 @@ ProcSyncQueryCounter(ClientPtr client)
&pCounter->value);
}
rep = (xSyncQueryCounterReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xSyncQueryCounterReply rep = (xSyncQueryCounterReply) {
.value_hi = pCounter->value >> 32,
.value_lo = pCounter->value
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.value_hi);
swapl(&rep.value_lo);
}
WriteToClient(client, sizeof(xSyncQueryCounterReply), &rep);
return Success;
REPLY_FIELD_CARD32(value_hi);
REPLY_FIELD_CARD32(value_lo);
REPLY_SEND_RET_SUCCESS();
}
/*
@ -1722,14 +1687,16 @@ ProcSyncQueryCounter(ClientPtr client)
static int
ProcSyncCreateAlarm(ClientPtr client)
{
REQUEST(xSyncCreateAlarmReq);
REQUEST_HEAD_AT_LEAST(xSyncCreateAlarmReq);
REQUEST_FIELD_CARD32(id);
REQUEST_FIELD_CARD32(valueMask);
REQUEST_REST_CARD32();
SyncAlarm *pAlarm;
int status;
unsigned long len, vmask;
SyncTrigger *pTrigger;
REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
LEGAL_NEW_RESOURCE(stuff->id, client);
vmask = stuff->valueMask;
@ -1805,14 +1772,16 @@ ProcSyncCreateAlarm(ClientPtr client)
static int
ProcSyncChangeAlarm(ClientPtr client)
{
REQUEST(xSyncChangeAlarmReq);
REQUEST_HEAD_AT_LEAST(xSyncChangeAlarmReq);
REQUEST_FIELD_CARD32(alarm);
REQUEST_FIELD_CARD32(valueMask);
REQUEST_REST_CARD32();
SyncAlarm *pAlarm;
SyncCounter *pCounter = NULL;
long vmask;
int len, status;
REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
status = dixLookupResourceByType((void **) &pAlarm, stuff->alarm, RTAlarm,
client, DixWriteAccess);
if (status != Success)
@ -1846,23 +1815,20 @@ ProcSyncChangeAlarm(ClientPtr client)
static int
ProcSyncQueryAlarm(ClientPtr client)
{
REQUEST(xSyncQueryAlarmReq);
REQUEST_HEAD_STRUCT(xSyncQueryAlarmReq);
REQUEST_FIELD_CARD32(alarm);
SyncAlarm *pAlarm;
xSyncQueryAlarmReply rep;
SyncTrigger *pTrigger;
int rc;
REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
rc = dixLookupResourceByType((void **) &pAlarm, stuff->alarm, RTAlarm,
client, DixReadAccess);
if (rc != Success)
return rc;
pTrigger = &pAlarm->trigger;
rep = (xSyncQueryAlarmReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
xSyncQueryAlarmReply rep = {
.length =
bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)),
.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None,
@ -1887,31 +1853,24 @@ ProcSyncQueryAlarm(ClientPtr client)
.state = pAlarm->state
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.counter);
swapl(&rep.wait_value_hi);
swapl(&rep.wait_value_lo);
swapl(&rep.test_type);
swapl(&rep.delta_hi);
swapl(&rep.delta_lo);
}
WriteToClient(client, sizeof(xSyncQueryAlarmReply), &rep);
return Success;
REPLY_FIELD_CARD32(counter);
REPLY_FIELD_CARD32(wait_value_hi);
REPLY_FIELD_CARD32(wait_value_lo);
REPLY_FIELD_CARD32(test_type);
REPLY_FIELD_CARD32(delta_hi);
REPLY_FIELD_CARD32(delta_lo);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcSyncDestroyAlarm(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xSyncDestroyAlarmReq);
REQUEST_FIELD_CARD32(alarm);
SyncAlarm *pAlarm;
int rc;
REQUEST(xSyncDestroyAlarmReq);
REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
rc = dixLookupResourceByType((void **) &pAlarm, stuff->alarm, RTAlarm,
client, DixDestroyAccess);
if (rc != Success)
@ -1924,13 +1883,14 @@ ProcSyncDestroyAlarm(ClientPtr client)
static int
ProcSyncCreateFence(ClientPtr client)
{
REQUEST(xSyncCreateFenceReq);
REQUEST_HEAD_STRUCT(xSyncCreateFenceReq);
REQUEST_FIELD_CARD32(d);
REQUEST_FIELD_CARD32(fid);
DrawablePtr pDraw;
SyncFence *pFence;
int rc;
REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -1970,12 +1930,12 @@ SyncVerifyFence(SyncFence ** ppSyncFence, XID fid, ClientPtr client, Mask mode)
static int
ProcSyncTriggerFence(ClientPtr client)
{
REQUEST(xSyncTriggerFenceReq);
REQUEST_HEAD_STRUCT(xSyncTriggerFenceReq);
REQUEST_FIELD_CARD32(fid);
SyncFence *pFence;
int rc;
REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
rc = dixLookupResourceByType((void **) &pFence, stuff->fid, RTFence,
client, DixWriteAccess);
if (rc != Success)
@ -1989,12 +1949,12 @@ ProcSyncTriggerFence(ClientPtr client)
static int
ProcSyncResetFence(ClientPtr client)
{
REQUEST(xSyncResetFenceReq);
REQUEST_HEAD_STRUCT(xSyncResetFenceReq);
REQUEST_FIELD_CARD32(fid);
SyncFence *pFence;
int rc;
REQUEST_SIZE_MATCH(xSyncResetFenceReq);
rc = dixLookupResourceByType((void **) &pFence, stuff->fid, RTFence,
client, DixWriteAccess);
if (rc != Success)
@ -2011,12 +1971,12 @@ ProcSyncResetFence(ClientPtr client)
static int
ProcSyncDestroyFence(ClientPtr client)
{
REQUEST(xSyncDestroyFenceReq);
REQUEST_HEAD_STRUCT(xSyncDestroyFenceReq);
REQUEST_FIELD_CARD32(fid);
SyncFence *pFence;
int rc;
REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
rc = dixLookupResourceByType((void **) &pFence, stuff->fid, RTFence,
client, DixDestroyAccess);
if (rc != Success)
@ -2029,39 +1989,30 @@ ProcSyncDestroyFence(ClientPtr client)
static int
ProcSyncQueryFence(ClientPtr client)
{
REQUEST(xSyncQueryFenceReq);
xSyncQueryFenceReply rep;
REQUEST_HEAD_STRUCT(xSyncQueryFenceReq);
REQUEST_FIELD_CARD32(fid);
SyncFence *pFence;
int rc;
REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
rc = dixLookupResourceByType((void **) &pFence, stuff->fid,
RTFence, client, DixReadAccess);
if (rc != Success)
return rc;
rep = (xSyncQueryFenceReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xSyncQueryFenceReply rep = (xSyncQueryFenceReply) {
.triggered = pFence->funcs.CheckTriggered(pFence)
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xSyncQueryFenceReply), &rep);
return Success;
REPLY_SEND_RET_SUCCESS();
}
static int
ProcSyncAwaitFence(ClientPtr client)
{
REQUEST(xSyncAwaitFenceReq);
REQUEST_HEAD_AT_LEAST(xSyncAwaitFenceReq);
REQUEST_REST_CARD32();
SyncAwaitUnion *pAwaitUnion;
SyncAwait *pAwait;
@ -2073,8 +2024,6 @@ ProcSyncAwaitFence(ClientPtr client)
int items;
int i;
REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
len = client->req_len << 2;
len -= sz_xSyncAwaitFenceReq;
items = len / sizeof(CARD32);
@ -2190,252 +2139,6 @@ ProcSyncDispatch(ClientPtr client)
}
}
/*
* Boring Swapping stuff ...
*/
static int _X_COLD
SProcSyncCreateCounter(ClientPtr client)
{
REQUEST(xSyncCreateCounterReq);
REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
swapl(&stuff->cid);
swapl(&stuff->initial_value_lo);
swapl(&stuff->initial_value_hi);
return ProcSyncCreateCounter(client);
}
static int _X_COLD
SProcSyncSetCounter(ClientPtr client)
{
REQUEST(xSyncSetCounterReq);
REQUEST_SIZE_MATCH(xSyncSetCounterReq);
swapl(&stuff->cid);
swapl(&stuff->value_lo);
swapl(&stuff->value_hi);
return ProcSyncSetCounter(client);
}
static int _X_COLD
SProcSyncChangeCounter(ClientPtr client)
{
REQUEST(xSyncChangeCounterReq);
REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
swapl(&stuff->cid);
swapl(&stuff->value_lo);
swapl(&stuff->value_hi);
return ProcSyncChangeCounter(client);
}
static int _X_COLD
SProcSyncQueryCounter(ClientPtr client)
{
REQUEST(xSyncQueryCounterReq);
REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
swapl(&stuff->counter);
return ProcSyncQueryCounter(client);
}
static int _X_COLD
SProcSyncDestroyCounter(ClientPtr client)
{
REQUEST(xSyncDestroyCounterReq);
REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
swapl(&stuff->counter);
return ProcSyncDestroyCounter(client);
}
static int _X_COLD
SProcSyncAwait(ClientPtr client)
{
REQUEST(xSyncAwaitReq);
REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
SwapRestL(stuff);
return ProcSyncAwait(client);
}
static int _X_COLD
SProcSyncCreateAlarm(ClientPtr client)
{
REQUEST(xSyncCreateAlarmReq);
REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
swapl(&stuff->id);
swapl(&stuff->valueMask);
SwapRestL(stuff);
return ProcSyncCreateAlarm(client);
}
static int _X_COLD
SProcSyncChangeAlarm(ClientPtr client)
{
REQUEST(xSyncChangeAlarmReq);
REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
swapl(&stuff->alarm);
swapl(&stuff->valueMask);
SwapRestL(stuff);
return ProcSyncChangeAlarm(client);
}
static int _X_COLD
SProcSyncQueryAlarm(ClientPtr client)
{
REQUEST(xSyncQueryAlarmReq);
REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
swapl(&stuff->alarm);
return ProcSyncQueryAlarm(client);
}
static int _X_COLD
SProcSyncDestroyAlarm(ClientPtr client)
{
REQUEST(xSyncDestroyAlarmReq);
REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
swapl(&stuff->alarm);
return ProcSyncDestroyAlarm(client);
}
static int _X_COLD
SProcSyncSetPriority(ClientPtr client)
{
REQUEST(xSyncSetPriorityReq);
REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
swapl(&stuff->id);
swapl(&stuff->priority);
return ProcSyncSetPriority(client);
}
static int _X_COLD
SProcSyncGetPriority(ClientPtr client)
{
REQUEST(xSyncGetPriorityReq);
REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
swapl(&stuff->id);
return ProcSyncGetPriority(client);
}
static int _X_COLD
SProcSyncCreateFence(ClientPtr client)
{
REQUEST(xSyncCreateFenceReq);
REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
swapl(&stuff->d);
swapl(&stuff->fid);
return ProcSyncCreateFence(client);
}
static int _X_COLD
SProcSyncTriggerFence(ClientPtr client)
{
REQUEST(xSyncTriggerFenceReq);
REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
swapl(&stuff->fid);
return ProcSyncTriggerFence(client);
}
static int _X_COLD
SProcSyncResetFence(ClientPtr client)
{
REQUEST(xSyncResetFenceReq);
REQUEST_SIZE_MATCH(xSyncResetFenceReq);
swapl(&stuff->fid);
return ProcSyncResetFence(client);
}
static int _X_COLD
SProcSyncDestroyFence(ClientPtr client)
{
REQUEST(xSyncDestroyFenceReq);
REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
swapl(&stuff->fid);
return ProcSyncDestroyFence(client);
}
static int _X_COLD
SProcSyncQueryFence(ClientPtr client)
{
REQUEST(xSyncQueryFenceReq);
REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
swapl(&stuff->fid);
return ProcSyncQueryFence(client);
}
static int _X_COLD
SProcSyncAwaitFence(ClientPtr client)
{
REQUEST(xSyncAwaitFenceReq);
REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
SwapRestL(stuff);
return ProcSyncAwaitFence(client);
}
static int _X_COLD
SProcSyncDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_SyncInitialize:
return ProcSyncInitialize(client);
case X_SyncListSystemCounters:
return ProcSyncListSystemCounters(client);
case X_SyncCreateCounter:
return SProcSyncCreateCounter(client);
case X_SyncSetCounter:
return SProcSyncSetCounter(client);
case X_SyncChangeCounter:
return SProcSyncChangeCounter(client);
case X_SyncQueryCounter:
return SProcSyncQueryCounter(client);
case X_SyncDestroyCounter:
return SProcSyncDestroyCounter(client);
case X_SyncAwait:
return SProcSyncAwait(client);
case X_SyncCreateAlarm:
return SProcSyncCreateAlarm(client);
case X_SyncChangeAlarm:
return SProcSyncChangeAlarm(client);
case X_SyncQueryAlarm:
return SProcSyncQueryAlarm(client);
case X_SyncDestroyAlarm:
return SProcSyncDestroyAlarm(client);
case X_SyncSetPriority:
return SProcSyncSetPriority(client);
case X_SyncGetPriority:
return SProcSyncGetPriority(client);
case X_SyncCreateFence:
return SProcSyncCreateFence(client);
case X_SyncTriggerFence:
return SProcSyncTriggerFence(client);
case X_SyncResetFence:
return SProcSyncResetFence(client);
case X_SyncDestroyFence:
return SProcSyncDestroyFence(client);
case X_SyncQueryFence:
return SProcSyncQueryFence(client);
case X_SyncAwaitFence:
return SProcSyncAwaitFence(client);
default:
return BadRequest;
}
}
/*
* Event Swapping
*/
@ -2509,7 +2212,7 @@ SyncExtensionInit(void)
RTAlarmClient == 0 ||
(extEntry = AddExtension(SYNC_NAME,
XSyncNumberEvents, XSyncNumberErrors,
ProcSyncDispatch, SProcSyncDispatch,
ProcSyncDispatch, ProcSyncDispatch,
SyncResetProc, StandardMinorOpcode)) == NULL) {
ErrorF("Sync Extension %d.%d failed to Initialise\n",
SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@ from The Open Group.
#include <X11/Xproto.h>
#include <X11/extensions/xcmiscproto.h>
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "misc.h"
@ -45,59 +46,49 @@ from The Open Group.
static int
ProcXCMiscGetVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXCMiscGetVersionReq);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
REQUEST_FIELD_CARD16(majorVersion);
REQUEST_FIELD_CARD16(minorVersion);
xXCMiscGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XCMiscMajorVersion,
.minorVersion = XCMiscMinorVersion
};
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xXCMiscGetVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(majorVersion);
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcXCMiscGetXIDRange(ClientPtr client)
{
xXCMiscGetXIDRangeReply rep;
XID min_id, max_id;
REQUEST_HEAD_STRUCT(xXCMiscGetXIDRangeReq);
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
XID min_id, max_id;
GetXIDRange(client->index, FALSE, &min_id, &max_id);
rep = (xXCMiscGetXIDRangeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXCMiscGetXIDRangeReply rep = {
.start_id = min_id,
.count = max_id - min_id + 1
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.start_id);
swapl(&rep.count);
}
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), &rep);
return Success;
REPLY_FIELD_CARD32(start_id);
REPLY_FIELD_CARD32(count);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcXCMiscGetXIDList(ClientPtr client)
{
REQUEST(xXCMiscGetXIDListReq);
xXCMiscGetXIDListReply rep;
REQUEST_HEAD_STRUCT(xXCMiscGetXIDListReq);
REQUEST_FIELD_CARD16(length);
REQUEST_FIELD_CARD32(count);
XID *pids;
unsigned int count;
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc;
@ -106,18 +97,15 @@ ProcXCMiscGetXIDList(ClientPtr client)
return BadAlloc;
}
count = GetXIDList(client, stuff->count, pids);
rep = (xXCMiscGetXIDListReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
xXCMiscGetXIDListReply rep = {
.length = count,
.count = count
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.count);
}
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep);
REPLY_FIELD_CARD32(length);
REPLY_FIELD_CARD32(count);
REPLY_SEND();
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
@ -142,46 +130,10 @@ ProcXCMiscDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcXCMiscGetVersion(ClientPtr client)
{
REQUEST(xXCMiscGetVersionReq);
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
swaps(&stuff->majorVersion);
swaps(&stuff->minorVersion);
return ProcXCMiscGetVersion(client);
}
static int _X_COLD
SProcXCMiscGetXIDList(ClientPtr client)
{
REQUEST(xXCMiscGetXIDListReq);
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
swapl(&stuff->count);
return ProcXCMiscGetXIDList(client);
}
static int _X_COLD
SProcXCMiscDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XCMiscGetVersion:
return SProcXCMiscGetVersion(client);
case X_XCMiscGetXIDRange:
return ProcXCMiscGetXIDRange(client);
case X_XCMiscGetXIDList:
return SProcXCMiscGetXIDList(client);
default:
return BadRequest;
}
}
void
XCMiscExtensionInit(void)
{
AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch,
ProcXCMiscDispatch, ProcXCMiscDispatch,
NULL, StandardMinorOpcode);
}

View File

@ -265,13 +265,9 @@ XF86BigfontResetProc(ExtensionEntry * extEntry)
static int
ProcXF86BigfontQueryVersion(ClientPtr client)
{
xXF86BigfontQueryVersionReply reply;
REQUEST_HEAD_STRUCT(xXF86BigfontQueryVersionReq);
REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
reply = (xXF86BigfontQueryVersionReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXF86BigfontQueryVersionReply reply = {
.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION,
.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION,
.uid = geteuid(),
@ -280,22 +276,14 @@ ProcXF86BigfontQueryVersion(ClientPtr client)
.signature = signature,
.capabilities = (client->local && !client->swapped)
? XF86Bigfont_CAP_LocalShm : 0
#else
.signature = 0,
.capabilities = 0
#endif
};
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swaps(&reply.majorVersion);
swaps(&reply.minorVersion);
swapl(&reply.uid);
swapl(&reply.gid);
swapl(&reply.signature);
}
WriteToClient(client, sizeof(xXF86BigfontQueryVersionReply), &reply);
return Success;
REPLY_FIELD_CARD16(&reply.majorVersion);
REPLY_FIELD_CARD16(&reply.minorVersion);
REPLY_FIELD_CARD32(&reply.uid);
REPLY_FIELD_CARD32(&reply.gid);
REPLY_FIELD_CARD32(&reply.signature);
REPLY_SEND_RET_SUCCESS();
}
static void
@ -319,9 +307,10 @@ swapCharInfo(xCharInfo * pCI)
static int
ProcXF86BigfontQueryFont(ClientPtr client)
{
FontPtr pFont;
REQUEST_HEAD_NO_CHECK(xXF86BigfontQueryFontReq);
REQUEST_FIELD_CARD32(id);
REQUEST(xXF86BigfontQueryFontReq);
FontPtr pFont;
CARD32 stuff_flags;
xCharInfo *pmax;
xCharInfo *pmin;
@ -538,9 +527,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
: 0);
xXF86BigfontQueryFontReply rep = {
.type = X_Reply;
.length = bytes_to_int32(buflength),
.sequenceNumber = client->sequence,
.minBounds = pFont->info.ink_minbounds,
.maxBounds = pFont->info.ink_maxbounds,
.minCharOrByte2 = pFont->info.firstCol,
@ -558,21 +545,20 @@ ProcXF86BigfontQueryFont(ClientPtr client)
.shmid = shmid,
};
REPLY_FIELD_CARD16(minCharOrByte2);
REPLY_FIELD_CARD16(maxCharOrByte2);
REPLY_FIELD_CARD16(defaultChar);
REPLY_FIELD_CARD16(nFontProps);
REPLY_FIELD_CARD16(fontAscent);
REPLY_FIELD_CARD16(fontDescent);
REPLY_FIELD_CARD32(nCharInfos);
REPLY_FIELD_CARD32(nUniqCharInfos);
REPLY_FIELD_CARD32(shmid);
REPLY_FIELD_CARD32(shmsegoffset);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapCharInfo(&rep.minBounds);
swapCharInfo(&rep.maxBounds);
swaps(&rep.minCharOrByte2);
swaps(&rep.maxCharOrByte2);
swaps(&rep.defaultChar);
swaps(&rep.nFontProps);
swaps(&rep.fontAscent);
swaps(&rep.fontDescent);
swapl(&rep.nCharInfos);
swapl(&rep.nUniqCharInfos);
swapl(&rep.shmid);
swapl(&rep.shmsegoffset);
}
int rc = Success;
@ -593,10 +579,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
i < nfontprops; i++, pFP++, prFP++) {
prFP->name = pFP->name;
prFP->value = pFP->value;
if (client->swapped) {
swapl(&prFP->name);
swapl(&prFP->value);
}
CLIENT_STRUCT_CARD32_2(prFP, name, value);
}
p = (char *) prFP;
}
@ -614,14 +597,11 @@ ProcXF86BigfontQueryFont(ClientPtr client)
ps = (CARD16 *) pci;
for (j = 0; j < nCharInfos; j++, ps++) {
*ps = pIndex2UniqIndex[j];
if (client->swapped) {
swaps(ps);
}
REPLY_BUF_CARD16(ps, 1);
}
}
WriteToClient(client, sizeof(xXF86BigfontQueryFontReply), &rep);
WriteToClient(client, rlength, buf);
REPLY_SEND_EXTRA(buf, rlength);
free(buf);
out:
if (nCharInfos > 0) {
@ -649,37 +629,6 @@ ProcXF86BigfontDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcXF86BigfontQueryVersion(ClientPtr client)
{
REQUEST(xXF86BigfontQueryVersionReq);
return ProcXF86BigfontQueryVersion(client);
}
static int _X_COLD
SProcXF86BigfontQueryFont(ClientPtr client)
{
REQUEST(xXF86BigfontQueryFontReq);
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
swapl(&stuff->id);
return ProcXF86BigfontQueryFont(client);
}
static int _X_COLD
SProcXF86BigfontDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XF86BigfontQueryVersion:
return SProcXF86BigfontQueryVersion(client);
case X_XF86BigfontQueryFont:
return SProcXF86BigfontQueryFont(client);
default:
return BadRequest;
}
}
void
XFree86BigfontExtensionInit(void)
{
@ -687,7 +636,7 @@ XFree86BigfontExtensionInit(void)
XF86BigfontNumberEvents,
XF86BigfontNumberErrors,
ProcXF86BigfontDispatch,
SProcXF86BigfontDispatch,
ProcXF86BigfontDispatch,
XF86BigfontResetProc, StandardMinorOpcode)) {
#ifdef MITSHM
#ifdef MUST_CHECK_FOR_SHM_SYSCALL

View File

@ -12,6 +12,7 @@
#include <X11/extensions/XResproto.h>
#include "dix/registry_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "os/client_priv.h"
#include "Xext/xace.h"
@ -28,7 +29,6 @@
#include "protocol-versions.h"
#include "list.h"
#include "misc.h"
#include <string.h>
#include "hashtable.h"
#include "picturestr.h"
#include "compint.h"
@ -112,21 +112,6 @@ AddFragment(struct xorg_list *frags, int bytes)
}
}
/** @brief Sends all fragments in the list to the client. Does not
free anything.
@param client The client to send the fragments to
@param frags The head of the list of fragments
*/
static void
WriteFragmentsToClient(ClientPtr client, struct xorg_list *frags)
{
FragmentList *it;
xorg_list_for_each_entry(it, frags, l) {
WriteToClient(client, it->bytes, (char*) it + sizeof(*it));
}
}
/** @brief Frees a list of fragments. Does not free() root node.
@param frags The head of the list of fragments
@ -196,40 +181,29 @@ DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
static int
ProcXResQueryVersion(ClientPtr client)
{
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
xXResQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.server_major = SERVER_XRES_MAJOR_VERSION,
.server_minor = SERVER_XRES_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
WriteToClient(client, sizeof(xXResQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(server_major);
REPLY_FIELD_CARD16(server_minor);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcXResQueryClients(ClientPtr client)
{
/* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep;
int i, num_clients;
REQUEST_HEAD_STRUCT(xXResQueryClientsReq);
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
int i, num_clients = 0;
int *current_clients = calloc(currentMaxClients, sizeof(int));
if (!current_clients)
return BadAlloc;
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
if (clients[i]) {
if (XaceHookClientAccess(client, clients[i], DixReadAccess) == Success) {
@ -239,36 +213,23 @@ ProcXResQueryClients(ClientPtr client)
}
}
rep = (xXResQueryClientsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_clients * sz_xXResClient),
xXResQueryClientsReply rep = {
.num_clients = num_clients
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_clients);
}
WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
xXResClient scratch[num_clients];
if (num_clients) {
xXResClient scratch;
for (i = 0; i < num_clients; i++) {
scratch.resource_base = clients[current_clients[i]]->clientAsMask;
scratch.resource_mask = RESOURCE_ID_MASK;
if (client->swapped) {
swapl(&scratch.resource_base);
swapl(&scratch.resource_mask);
}
WriteToClient(client, sz_xXResClient, &scratch);
scratch[i].resource_base = clients[current_clients[i]]->clientAsMask;
scratch[i].resource_mask = RESOURCE_ID_MASK;
CLIENT_STRUCT_CARD32_2(&scratch[i], resource_base, resource_mask);
}
}
REPLY_FIELD_CARD32(num_clients);
REPLY_SEND_EXTRA(scratch, sizeof(scratch));
free(current_clients);
return Success;
}
@ -301,11 +262,8 @@ resourceTypeAtom(int i)
static int
ProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, num_types;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
REQUEST_HEAD_STRUCT(xXResQueryClientResourcesReq);
REQUEST_FIELD_CARD32(xid);
ClientPtr resClient = dixClientForXID(stuff->xid);
@ -322,47 +280,30 @@ ProcXResQueryClientResources(ClientPtr client)
FindAllClientResources(resClient, ResFindAllRes, counts);
num_types = 0;
int cnt[lastResourceType + 1];
for (i = 0; i <= lastResourceType; i++) {
if (counts[i])
if (counts[i]) {
cnt[num_types] = counts[i];
num_types++;
}
rep = (xXResQueryClientResourcesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_types * sz_xXResType),
.num_types = num_types
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_types);
}
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
if (num_types) {
xXResType scratch;
for (i = 0; i < lastResourceType; i++) {
if (!counts[i])
continue;
scratch.resource_type = resourceTypeAtom(i + 1);
scratch.count = counts[i];
if (client->swapped) {
swapl(&scratch.resource_type);
swapl(&scratch.count);
}
WriteToClient(client, sz_xXResType, &scratch);
}
}
free(counts);
xXResQueryClientResourcesReply rep = {
.num_types = num_types
};
xXResType scratch[num_types];
for (i = 0; i < num_types; i++) {
scratch[i].resource_type = resourceTypeAtom(i + 1);
scratch[i].count = cnt[i];
CLIENT_STRUCT_CARD32_2(&scratch[i], resource_type, count);
}
REPLY_FIELD_CARD32(num_types);
REPLY_SEND_EXTRA(scratch, sizeof(scratch));
free(counts);
return Success;
}
@ -380,10 +321,8 @@ ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
static int
ProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
REQUEST_HEAD_STRUCT(xXResQueryClientPixmapBytesReq);
REQUEST_FIELD_CARD32(xid);
ClientPtr owner = dixClientForXID(stuff->xid);
if ((!owner) ||
@ -397,26 +336,15 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
FindAllClientResources(owner, ResFindResourcePixmaps,
(void *) (&bytes));
rep = (xXResQueryClientPixmapBytesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXResQueryClientPixmapBytesReply rep = {
.bytes = bytes,
#ifdef _XSERVER64
.bytes_overflow = bytes >> 32
#else
.bytes_overflow = 0
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.bytes);
swapl(&rep.bytes_overflow);
}
WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply), &rep);
return Success;
REPLY_FIELD_CARD32(bytes);
REPLY_FIELD_CARD32(bytes_overflow);
REPLY_SEND_RET_SUCCESS();
}
/** @brief Finds out if a client's information need to be put into the
@ -464,12 +392,11 @@ static Bool
ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx)
{
xXResClientIdValue rep;
xXResClientIdValue rep = {
.spec.client = client->clientAsMask,
};
rep.spec.client = client->clientAsMask;
if (client->swapped) {
swapl (&rep.spec.client);
}
REPLY_FIELD_CARD32(spec.client);
if (WillConstructMask(client, mask, ctx, X_XResClientXIDMask)) {
void *ptr = AddFragment(&ctx->response, sizeof(rep));
@ -478,11 +405,7 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
}
rep.spec.mask = X_XResClientXIDMask;
rep.length = 0;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
/* swapl (&rep.length, n); - not required for rep.length = 0 */
}
REPLY_FIELD_CARD32(spec.mask);
memcpy(ptr, &rep, sizeof(rep));
@ -504,14 +427,11 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
rep.spec.mask = X_XResLocalClientPIDMask;
rep.length = 4;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
swapl (&rep.length);
}
REPLY_FIELD_CARD32(spec.mask);
REPLY_FIELD_CARD32(length); // need to do it, since not calling REPLY_SEND()
REPLY_BUF_CARD32(value, 1);
if (sendClient->swapped) {
swapl (value);
}
memcpy(ptr, &rep, sizeof(rep));
*value = pid;
@ -580,7 +500,8 @@ ConstructClientIds(ClientPtr client,
static int
ProcXResQueryClientIds (ClientPtr client)
{
REQUEST(xXResQueryClientIdsReq);
REQUEST_HEAD_AT_LEAST(xXResQueryClientIdsReq);
REQUEST_FIELD_CARD32(numSpecs);
xXResClientIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
int rc;
@ -588,30 +509,28 @@ ProcXResQueryClientIds (ClientPtr client)
InitConstructClientIdCtx(&ctx);
REQUEST_AT_LEAST_SIZE(xXResQueryClientIdsReq);
REQUEST_FIXED_SIZE(xXResQueryClientIdsReq,
stuff->numSpecs * sizeof(specs[0]));
rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx);
if (rc == Success) {
xXResQueryClientIdsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
char buf[ctx.resultBytes];
char *walk = buf;
FragmentList *it;
xorg_list_for_each_entry(it, &ctx.response, l) {
memcpy(walk, FRAGMENT_DATA(it), it->bytes);
walk += it->bytes;
}
xXResQueryClientIdsReply rep = {
.length = bytes_to_int32(ctx.resultBytes),
.numIds = ctx.numIds
};
assert((ctx.resultBytes & 3) == 0);
if (client->swapped) {
swaps (&rep.sequenceNumber);
swapl (&rep.length);
swapl (&rep.numIds);
}
WriteToClient(client, sizeof(rep), &rep);
WriteFragmentsToClient(client, &ctx.response);
REPLY_FIELD_CARD32(numIds);
REPLY_SEND_EXTRA(buf, sizeof(buf));
}
DestroyConstructClientIdCtx(&ctx);
@ -951,17 +870,24 @@ ConstructResourceBytes(XID aboutClient,
static int
ProcXResQueryResourceBytes (ClientPtr client)
{
REQUEST(xXResQueryResourceBytesReq);
REQUEST_HEAD_AT_LEAST(xXResQueryResourceBytesReq);
REQUEST_FIELD_CARD32(numSpecs);
int rc;
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
if (client->swapped) {
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
for (int c = 0; c < stuff->numSpecs; ++c) {
SwapXResResourceIdSpec(specs + c);
}
}
if (!InitConstructResourceBytesCtx(&ctx, client,
stuff->numSpecs,
(void*) ((char*) stuff +
@ -973,22 +899,26 @@ ProcXResQueryResourceBytes (ClientPtr client)
if (rc == Success) {
xXResQueryResourceBytesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(ctx.resultBytes),
.numSizes = ctx.numSizes
};
if (client->swapped) {
swaps (&rep.sequenceNumber);
swapl (&rep.length);
swapl (&rep.numSizes);
REPLY_FIELD_CARD32(numSizes);
if (client->swapped) {
SwapXResQueryResourceBytes(&ctx.response);
}
WriteToClient(client, sizeof(rep), &rep);
WriteFragmentsToClient(client, &ctx.response);
char buf[ctx.resultBytes];
{
char *walk = buf;
FragmentList *it;
xorg_list_for_each_entry(it, &ctx.response, l) {
memcpy(walk, FRAGMENT_DATA(it), it->bytes);
walk += it->bytes;
}
}
REPLY_SEND_EXTRA(buf, sizeof(buf));
}
DestroyConstructResourceBytesCtx(&ctx);
@ -1019,91 +949,10 @@ ProcResDispatch(ClientPtr client)
return BadRequest;
}
static int _X_COLD
SProcXResQueryVersion(ClientPtr client)
{
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
return ProcXResQueryVersion(client);
}
static int _X_COLD
SProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
swapl(&stuff->xid);
return ProcXResQueryClientResources(client);
}
static int _X_COLD
SProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
swapl(&stuff->xid);
return ProcXResQueryClientPixmapBytes(client);
}
static int _X_COLD
SProcXResQueryClientIds (ClientPtr client)
{
REQUEST(xXResQueryClientIdsReq);
REQUEST_AT_LEAST_SIZE (xXResQueryClientIdsReq);
swapl(&stuff->numSpecs);
return ProcXResQueryClientIds(client);
}
/** @brief Implements the XResQueryResourceBytes of XResProto v1.2.
This variant byteswaps request contents before issuing the
rest of the work to ProcXResQueryResourceBytes */
static int _X_COLD
SProcXResQueryResourceBytes (ClientPtr client)
{
REQUEST(xXResQueryResourceBytesReq);
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0]));
for (c = 0; c < stuff->numSpecs; ++c) {
SwapXResResourceIdSpec(specs + c);
}
return ProcXResQueryResourceBytes(client);
}
static int _X_COLD
SProcResDispatch (ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XResQueryVersion:
return SProcXResQueryVersion(client);
case X_XResQueryClients: /* nothing to swap */
return ProcXResQueryClients(client);
case X_XResQueryClientResources:
return SProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return SProcXResQueryClientPixmapBytes(client);
case X_XResQueryClientIds:
return SProcXResQueryClientIds(client);
case X_XResQueryResourceBytes:
return SProcXResQueryResourceBytes(client);
default: break;
}
return BadRequest;
}
void
ResExtensionInit(void)
{
(void) AddExtension(XRES_NAME, 0, 0,
ProcResDispatch, SProcResDispatch,
ProcResDispatch, ProcResDispatch,
NULL, StandardMinorOpcode);
}

View File

@ -21,6 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/property_priv.h"
#include "dix/request_priv.h"
#include "selection.h"
#include "inputstr.h"
@ -68,19 +69,13 @@ static int
ProcSELinuxQueryVersion(ClientPtr client)
{
SELinuxQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.server_major = SELINUX_MAJOR_VERSION,
.server_minor = SELINUX_MINOR_VERSION
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
WriteToClient(client, sizeof(rep), &rep);
return Success;
REPLY_FIELD_CARD16(server_major);
REPLY_FIELD_CARD16(server_minor);
REPLY_SEND_RET_SUCCESS();
}
static int
@ -96,20 +91,11 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
}
SELinuxGetContextReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(len),
.context_len = len
};
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.context_len);
}
WriteToClient(client, sizeof(SELinuxGetContextReply), &rep);
WriteToClient(client, len, ctx);
REPLY_FIELD_CARD32(context_len);
REPLY_SEND_EXTRA(ctx, len);
freecon(ctx);
return Success;
}
@ -123,7 +109,8 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
char *ptr;
int rc;
REQUEST(SELinuxSetCreateContextReq);
REQUEST_HEAD_AT_LEAST(SELinuxSetCreateContextReq);
REQUEST_FIELD_CARD32(context_len);
REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len);
if (stuff->context_len > 0) {
@ -153,7 +140,7 @@ ProcSELinuxGetCreateContext(ClientPtr client, unsigned offset)
security_id_t *pSid;
char *ptr;
REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetCreateContextReq);
if (offset == CTX_DEV)
ptr = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
@ -174,7 +161,9 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
SELinuxObjectRec *obj;
int rc;
REQUEST(SELinuxSetContextReq);
REQUEST_HEAD_AT_LEAST(SELinuxSetContextReq);
REQUEST_FIELD_CARD32(id);
REQUEST_FIELD_CARD32(context_len);
REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
if (stuff->context_len < 1)
@ -211,8 +200,8 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
SELinuxSubjectRec *subj;
int rc;
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
REQUEST_FIELD_CARD32(id);
rc = dixLookupDevice(&dev, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
@ -230,8 +219,8 @@ ProcSELinuxGetDrawableContext(ClientPtr client)
SELinuxObjectRec *obj;
int rc;
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
REQUEST_FIELD_CARD32(id);
rc = dixLookupDrawable(&pDraw, stuff->id, client, 0, DixGetAttrAccess);
if (rc != Success)
@ -254,8 +243,9 @@ ProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
SELinuxObjectRec *obj;
int rc;
REQUEST(SELinuxGetPropertyContextReq);
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetPropertyContextReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD32(property);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetPropAccess);
if (rc != Success)
@ -277,8 +267,8 @@ ProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
SELinuxObjectRec *obj;
int rc;
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
REQUEST_FIELD_CARD32(id);
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
@ -295,8 +285,8 @@ ProcSELinuxGetClientContext(ClientPtr client)
SELinuxSubjectRec *subj;
int rc;
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
REQUEST_FIELD_CARD32(id);
rc = dixLookupResourceOwner(&target, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
@ -348,10 +338,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
int size, int count)
{
int rc = BadAlloc, k, pos = 0;
CARD32 *buf = calloc(size, sizeof(CARD32));
if (size && !buf) {
goto out;
}
CARD32 buf[size];
if (!buf) // silence analyzer warning
goto sendreply;
@ -359,18 +346,15 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
/* Fill in the buffer */
for (k = 0; k < count; k++) {
buf[pos] = items[k].id;
if (client->swapped)
swapl(buf + pos);
REPLY_BUF_CARD32(buf + pos, 1);
pos++;
buf[pos] = items[k].octx_len * 4;
if (client->swapped)
swapl(buf + pos);
REPLY_BUF_CARD32(buf + pos, 1);
pos++;
buf[pos] = items[k].dctx_len * 4;
if (client->swapped)
swapl(buf + pos);
REPLY_BUF_CARD32(buf + pos, 1);
pos++;
memcpy((char *) (buf + pos), items[k].octx, strlen(items[k].octx) + 1);
@ -382,27 +366,15 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
sendreply: ;
/* Send reply to client */
SELinuxListItemsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = size,
.count = count
};
if (client->swapped) {
swapl(&rep.length);
swaps(&rep.sequenceNumber);
swapl(&rep.count);
}
WriteToClient(client, sizeof(SELinuxListItemsReply), &rep);
WriteToClient(client, size * 4, buf);
REPLY_FIELD_CARD32(count);
REPLY_SEND_EXTRA(buf, size * sizeof(CARD32));
/* Free stuff and return */
rc = Success;
free(buf);
out:
SELinuxFreeItems(items, count);
return rc;
return Success;
}
static int
@ -414,8 +386,8 @@ ProcSELinuxListProperties(ClientPtr client)
int rc, count, size, i;
CARD32 id;
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetContextReq);
REQUEST_FIELD_CARD32(id);
rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
if (rc != Success)
@ -453,7 +425,7 @@ ProcSELinuxListSelections(ClientPtr client)
int rc, count, size, i;
CARD32 id;
REQUEST_SIZE_MATCH(SELinuxGetCreateContextReq);
REQUEST_HEAD_STRUCT(SELinuxGetCreateContextReq);
/* Count the number of selections and allocate items */
count = 0;
@ -535,151 +507,6 @@ ProcSELinuxDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcSELinuxQueryVersion(ClientPtr client)
{
return ProcSELinuxQueryVersion(client);
}
static int _X_COLD
SProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
{
REQUEST(SELinuxSetCreateContextReq);
REQUEST_AT_LEAST_SIZE(SELinuxSetCreateContextReq);
swapl(&stuff->context_len);
return ProcSELinuxSetCreateContext(client, offset);
}
static int _X_COLD
SProcSELinuxSetDeviceContext(ClientPtr client)
{
REQUEST(SELinuxSetContextReq);
REQUEST_AT_LEAST_SIZE(SELinuxSetContextReq);
swapl(&stuff->id);
swapl(&stuff->context_len);
return ProcSELinuxSetDeviceContext(client);
}
static int _X_COLD
SProcSELinuxGetDeviceContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
return ProcSELinuxGetDeviceContext(client);
}
static int _X_COLD
SProcSELinuxGetDrawableContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
return ProcSELinuxGetDrawableContext(client);
}
static int _X_COLD
SProcSELinuxGetPropertyContext(ClientPtr client, void *privKey)
{
REQUEST(SELinuxGetPropertyContextReq);
REQUEST_SIZE_MATCH(SELinuxGetPropertyContextReq);
swapl(&stuff->window);
swapl(&stuff->property);
return ProcSELinuxGetPropertyContext(client, privKey);
}
static int _X_COLD
SProcSELinuxGetSelectionContext(ClientPtr client, void *privKey)
{
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
return ProcSELinuxGetSelectionContext(client, privKey);
}
static int _X_COLD
SProcSELinuxListProperties(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
return ProcSELinuxListProperties(client);
}
static int _X_COLD
SProcSELinuxGetClientContext(ClientPtr client)
{
REQUEST(SELinuxGetContextReq);
REQUEST_SIZE_MATCH(SELinuxGetContextReq);
swapl(&stuff->id);
return ProcSELinuxGetClientContext(client);
}
static int _X_COLD
SProcSELinuxDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_SELinuxQueryVersion:
return SProcSELinuxQueryVersion(client);
case X_SELinuxSetDeviceCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_DEV);
case X_SELinuxGetDeviceCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_DEV);
case X_SELinuxSetDeviceContext:
return SProcSELinuxSetDeviceContext(client);
case X_SELinuxGetDeviceContext:
return SProcSELinuxGetDeviceContext(client);
case X_SELinuxSetDrawableCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_WIN);
case X_SELinuxGetDrawableContext:
return SProcSELinuxGetDrawableContext(client);
case X_SELinuxSetPropertyCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_PRP);
case X_SELinuxGetPropertyCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_PRP);
case X_SELinuxSetPropertyUseContext:
return SProcSELinuxSetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyUseContext:
return ProcSELinuxGetCreateContext(client, USE_PRP);
case X_SELinuxGetPropertyContext:
return SProcSELinuxGetPropertyContext(client, objectKey);
case X_SELinuxGetPropertyDataContext:
return SProcSELinuxGetPropertyContext(client, dataKey);
case X_SELinuxListProperties:
return SProcSELinuxListProperties(client);
case X_SELinuxSetSelectionCreateContext:
return SProcSELinuxSetCreateContext(client, CTX_SEL);
case X_SELinuxGetSelectionCreateContext:
return ProcSELinuxGetCreateContext(client, CTX_SEL);
case X_SELinuxSetSelectionUseContext:
return SProcSELinuxSetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionUseContext:
return ProcSELinuxGetCreateContext(client, USE_SEL);
case X_SELinuxGetSelectionContext:
return SProcSELinuxGetSelectionContext(client, objectKey);
case X_SELinuxGetSelectionDataContext:
return SProcSELinuxGetSelectionContext(client, dataKey);
case X_SELinuxListSelections:
return ProcSELinuxListSelections(client);
case X_SELinuxGetClientContext:
return SProcSELinuxGetClientContext(client);
default:
return BadRequest;
}
}
/*
* Extension Setup / Teardown
*/
@ -715,5 +542,5 @@ SELinuxExtensionInit(void)
/* Add extension to server */
AddExtension(SELINUX_EXTENSION_NAME, SELinuxNumberEvents,
SELinuxNumberErrors, ProcSELinuxDispatch,
SProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
ProcSELinuxDispatch, SELinuxResetProc, StandardMinorOpcode);
}

View File

@ -38,6 +38,7 @@
#include "dix/input_priv.h"
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "mi/mi_priv.h"
#include "mi/mipointer_priv.h"
#include "os/client_priv.h"
@ -89,35 +90,30 @@ static int XTestSwapFakeInput(ClientPtr /* client */ ,
static int
ProcXTestGetVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXTestGetVersionReq);
REQUEST_FIELD_CARD16(minorVersion);
xXTestGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = XTestMajorVersion,
.minorVersion = XTestMinorVersion
};
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.minorVersion);
}
WriteToClient(client, sizeof(xXTestGetVersionReply), &rep);
return Success;
REPLY_FIELD_CARD16(minorVersion);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcXTestCompareCursor(ClientPtr client)
{
REQUEST(xXTestCompareCursorReq);
xXTestCompareCursorReply rep;
REQUEST_HEAD_STRUCT(xXTestCompareCursorReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD32(cursor);
WindowPtr pWin;
CursorPtr pCursor;
int rc;
DeviceIntPtr ptr = PickPointer(client);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -137,17 +133,11 @@ ProcXTestCompareCursor(ClientPtr client)
return rc;
}
}
rep = (xXTestCompareCursorReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXTestCompareCursorReply rep = {
.same = (wCursor(pWin) == pCursor)
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xXTestCompareCursorReply), &rep);
return Success;
REPLY_SEND_RET_SUCCESS();
}
void
@ -182,7 +172,14 @@ XTestDeviceSendEvents(DeviceIntPtr dev,
static int
ProcXTestFakeInput(ClientPtr client)
{
REQUEST(xXTestFakeInputReq);
REQUEST_HEAD_NO_CHECK(xXTestFakeInputReq);
if (client->swapped) {
int n = XTestSwapFakeInput(client, (xReq *)stuff);
if (n != Success)
return n;
}
int nev, n, type, rc;
xEvent *ev;
DeviceIntPtr dev = NULL;
@ -372,6 +369,7 @@ ProcXTestFakeInput(ClientPtr client)
/* swap the request back so we can simply re-execute it */
if (client->swapped) {
(void) XTestSwapFakeInput(client, (xReq *) stuff);
REQUEST_FIELD_CARD16(length);
}
ResetCurrentRequest(client);
client->sequence--;
@ -449,9 +447,8 @@ ProcXTestFakeInput(ClientPtr client)
static int
ProcXTestGrabControl(ClientPtr client)
{
REQUEST(xXTestGrabControlReq);
REQUEST_HEAD_STRUCT(xXTestGrabControlReq);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) {
client->errorValue = stuff->impervious;
return BadValue;
@ -481,25 +478,6 @@ ProcXTestDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcXTestGetVersion(ClientPtr client)
{
REQUEST(xXTestGetVersionReq);
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion);
return ProcXTestGetVersion(client);
}
static int _X_COLD
SProcXTestCompareCursor(ClientPtr client)
{
REQUEST(xXTestCompareCursorReq);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window);
swapl(&stuff->cursor);
return ProcXTestCompareCursor(client);
}
static int _X_COLD
XTestSwapFakeInput(ClientPtr client, xReq * req)
{
@ -524,37 +502,6 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
return Success;
}
static int _X_COLD
SProcXTestFakeInput(ClientPtr client)
{
int n;
REQUEST(xReq);
n = XTestSwapFakeInput(client, stuff);
if (n != Success)
return n;
return ProcXTestFakeInput(client);
}
static int _X_COLD
SProcXTestDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XTestGetVersion:
return SProcXTestGetVersion(client);
case X_XTestCompareCursor:
return SProcXTestCompareCursor(client);
case X_XTestFakeInput:
return SProcXTestFakeInput(client);
case X_XTestGrabControl:
return ProcXTestGrabControl(client);
default:
return BadRequest;
}
}
/**
* Allocate an virtual slave device for xtest events, this
* is a slave device to inputInfo master devices
@ -686,7 +633,7 @@ void
XTestExtensionInit(void)
{
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
ProcXTestDispatch, ProcXTestDispatch,
XTestExtensionTearDown, StandardMinorOpcode);
xtest_evlist = InitEventList(GetMaximumEventsNum());

File diff suppressed because it is too large Load Diff

View File

@ -183,7 +183,7 @@ XvExtensionInit(void)
XvExtensionGeneration = serverGeneration;
extEntry = AddExtension(XvName, XvNumEvents, XvNumErrors,
ProcXvDispatch, SProcXvDispatch,
ProcXvDispatch, ProcXvDispatch,
XvResetProc, StandardMinorOpcode);
if (!extEntry) {
FatalError("XvExtensionInit: AddExtensions failed\n");

View File

@ -4,7 +4,12 @@
#include <string.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/Xfuncproto.h>
#include <X11/extensions/XvMC.h>
#include <X11/extensions/Xvproto.h>
#include <X11/extensions/XvMCproto.h>
#include "dix/request_priv.h"
#include "dix/screen_hooks_priv.h"
#include "Xext/xvdix_priv.h"
@ -16,10 +21,6 @@
#include "extnsionst.h"
#include "extinit_priv.h"
#include "servermd.h"
#include <X11/Xfuncproto.h>
#include <X11/extensions/XvMC.h>
#include <X11/extensions/Xvproto.h>
#include <X11/extensions/XvMCproto.h>
#include "xvmcext.h"
#ifdef HAS_XVMCSHM
@ -109,35 +110,27 @@ XvMCDestroySubpictureRes(void *data, XID id)
static int
ProcXvMCQueryVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcQueryVersionReq);
xvmcQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.major = SERVER_XVMC_MAJOR_VERSION,
.minor = SERVER_XVMC_MINOR_VERSION
};
/* REQUEST(xvmcQueryVersionReq); */
REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
WriteToClient(client, sizeof(xvmcQueryVersionReply), &rep);
return Success;
REPLY_FIELD_CARD32(major);
REPLY_FIELD_CARD32(minor);
REPLY_SEND_RET_SUCCESS();
}
static int
ProcXvMCListSurfaceTypes(ClientPtr client)
{
XvPortPtr pPort;
int i;
XvMCScreenPtr pScreenPriv;
xvmcListSurfaceTypesReply rep;
xvmcSurfaceInfo info;
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface;
int num_surfaces;
REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
REQUEST_HEAD_STRUCT(xvmcListSurfaceTypesReq);
REQUEST_FIELD_CARD32(port);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
@ -145,7 +138,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if ((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for (i = 0; i < pScreenPriv->num_adaptors; i++) {
for (int i = 0; i < pScreenPriv->num_adaptors; i++) {
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
adaptor = &(pScreenPriv->adaptors[i]);
break;
@ -154,29 +147,33 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
}
}
num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
rep = (xvmcListSurfaceTypesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num = num_surfaces,
.length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)),
};
int num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
xvmcSurfaceInfo *info = calloc(sizeof(xvmcSurfaceInfo), num_surfaces);
if (!info)
return BadAlloc;
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep);
for (int i = 0; i < num_surfaces; i++) {
XvMCSurfaceInfoPtr surface = adaptor->surfaces[i];
info[i].surface_type_id = surface->surface_type_id;
info[i].chroma_format = surface->chroma_format;
info[i].max_width = surface->max_width;
info[i].max_height = surface->max_height;
info[i].subpicture_max_width = surface->subpicture_max_width;
info[i].subpicture_max_height = surface->subpicture_max_height;
info[i].mc_type = surface->mc_type;
info[i].flags = surface->flags;
for (i = 0; i < num_surfaces; i++) {
surface = adaptor->surfaces[i];
info.surface_type_id = surface->surface_type_id;
info.chroma_format = surface->chroma_format;
info.max_width = surface->max_width;
info.max_height = surface->max_height;
info.subpicture_max_width = surface->subpicture_max_width;
info.subpicture_max_height = surface->subpicture_max_height;
info.mc_type = surface->mc_type;
info.flags = surface->flags;
WriteToClient(client, sizeof(xvmcSurfaceInfo), &info);
CLIENT_STRUCT_CARD16_5(&info[i], chroma_format, max_width, max_height,
subpicture_max_width, subpicture_max_height);
CLIENT_STRUCT_CARD32_3(&info[i], surface_type_id, mc_type, flags);
}
xvmcListSurfaceTypesReply rep = {
.num = num_surfaces,
};
REPLY_FIELD_CARD32(num);
REPLY_SEND_EXTRA(info, sizeof(xvmcSurfaceInfo) * num_surfaces);
return Success;
}
@ -192,10 +189,12 @@ ProcXvMCCreateContext(ClientPtr client)
XvMCScreenPtr pScreenPriv;
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface = NULL;
xvmcCreateContextReply rep;
REQUEST(xvmcCreateContextReq);
REQUEST_SIZE_MATCH(xvmcCreateContextReq);
REQUEST_HEAD_STRUCT(xvmcCreateContextReq);
REQUEST_FIELD_CARD32(context_id);
REQUEST_FIELD_CARD16(width);
REQUEST_FIELD_CARD16(height);
REQUEST_FIELD_CARD32(flags);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
@ -257,33 +256,31 @@ ProcXvMCCreateContext(ClientPtr client)
return BadAlloc;
}
rep = (xvmcCreateContextReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords,
xvmcCreateContextReply rep = {
.width_actual = pContext->width,
.height_actual = pContext->height,
.flags_return = pContext->flags
};
WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
if (dwords)
WriteToClient(client, dwords << 2, data);
REPLY_FIELD_CARD16(width_actual);
REPLY_FIELD_CARD16(height_actual);
REPLY_FIELD_CARD32(flags_return);
REPLY_BUF_CARD32(data, dwords);
REPLY_SEND_EXTRA(data, dwords * sizeof(CARD32));
free(data);
return Success;
}
static int
ProcXvMCDestroyContext(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcDestroyContextReq);
REQUEST_FIELD_CARD32(context_id);
void *val;
int rc;
REQUEST(xvmcDestroyContextReq);
REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
client, DixDestroyAccess);
if (rc != Success)
@ -297,16 +294,16 @@ ProcXvMCDestroyContext(ClientPtr client)
static int
ProcXvMCCreateSurface(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcCreateSurfaceReq);
REQUEST_FIELD_CARD32(surface_id);
REQUEST_FIELD_CARD32(context_id);
CARD32 *data = NULL;
int dwords = 0;
int result;
XvMCContextPtr pContext;
XvMCSurfacePtr pSurface;
XvMCScreenPtr pScreenPriv;
xvmcCreateSurfaceReply rep;
REQUEST(xvmcCreateSurfaceReq);
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
XvMCRTContext, client, DixUseAccess);
@ -336,15 +333,10 @@ ProcXvMCCreateSurface(ClientPtr client)
return BadAlloc;
}
rep = (xvmcCreateSurfaceReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords
};
xvmcCreateSurfaceReply rep = { 0 };
WriteToClient(client, sizeof(xvmcCreateSurfaceReply), &rep);
if (dwords)
WriteToClient(client, dwords << 2, data);
REPLY_BUF_CARD32(data, dwords);
REPLY_SEND_EXTRA(data, dwords * sizeof(CARD32));
free(data);
@ -356,12 +348,12 @@ ProcXvMCCreateSurface(ClientPtr client)
static int
ProcXvMCDestroySurface(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcDestroySurfaceReq);
REQUEST_FIELD_CARD32(surface_id);
void *val;
int rc;
REQUEST(xvmcDestroySurfaceReq);
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
client, DixDestroyAccess);
if (rc != Success)
@ -375,19 +367,22 @@ ProcXvMCDestroySurface(ClientPtr client)
static int
ProcXvMCCreateSubpicture(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcCreateSubpictureReq);
REQUEST_FIELD_CARD32(subpicture_id);
REQUEST_FIELD_CARD32(context_id);
REQUEST_FIELD_CARD32(xvimage_id);
REQUEST_FIELD_CARD16(width);
REQUEST_FIELD_CARD16(height);
Bool image_supported = FALSE;
CARD32 *data = NULL;
int i, result, dwords = 0;
XvMCContextPtr pContext;
XvMCSubpicturePtr pSubpicture;
XvMCScreenPtr pScreenPriv;
xvmcCreateSubpictureReply rep;
XvMCAdaptorPtr adaptor;
XvMCSurfaceInfoPtr surface = NULL;
REQUEST(xvmcCreateSubpictureReq);
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
XvMCRTContext, client, DixUseAccess);
if (result != Success)
@ -456,10 +451,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
return BadAlloc;
}
rep = (xvmcCreateSubpictureReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = dwords,
xvmcCreateSubpictureReply rep = {
.width_actual = pSubpicture->width,
.height_actual = pSubpicture->height,
.num_palette_entries = pSubpicture->num_palette_entries,
@ -470,9 +462,12 @@ ProcXvMCCreateSubpicture(ClientPtr client)
.component_order[3] = pSubpicture->component_order[3]
};
WriteToClient(client, sizeof(xvmcCreateSubpictureReply), &rep);
if (dwords)
WriteToClient(client, dwords << 2, data);
REPLY_FIELD_CARD16(width_actual);
REPLY_FIELD_CARD16(height_actual);
REPLY_FIELD_CARD16(num_palette_entries);
REPLY_FIELD_CARD16(entry_bytes);
REPLY_BUF_CARD32(data, dwords);
REPLY_SEND_EXTRA(data, dwords * sizeof(CARD32));
free(data);
@ -484,12 +479,12 @@ ProcXvMCCreateSubpicture(ClientPtr client)
static int
ProcXvMCDestroySubpicture(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcDestroySubpictureReq);
REQUEST_FIELD_CARD32(subpicture_id);
void *val;
int rc;
REQUEST(xvmcDestroySubpictureReq);
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
client, DixDestroyAccess);
if (rc != Success)
@ -503,19 +498,18 @@ ProcXvMCDestroySubpicture(ClientPtr client)
static int
ProcXvMCListSubpictureTypes(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xvmcListSubpictureTypesReq);
REQUEST_FIELD_CARD32(port);
REQUEST_FIELD_CARD32(surface_type_id);
XvPortPtr pPort;
xvmcListSubpictureTypesReply rep;
XvMCScreenPtr pScreenPriv;
ScreenPtr pScreen;
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface = NULL;
xvImageFormatInfo info;
XvImagePtr pImage;
int i, j;
REQUEST(xvmcListSubpictureTypesReq);
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
pScreen = pPort->pAdaptor->pScreen;
@ -546,19 +540,11 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!surface)
return BadMatch;
rep = (xvmcListSubpictureTypesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num = 0
};
if (surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
int num = (surface->compatible_subpictures ?
surface->compatible_subpictures->num_xvimages : 0);
rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
for (i = 0; i < rep.num; i++) {
xvImageFormatInfo info[num];
for (i = 0; i < num; i++) {
pImage = NULL;
for (j = 0; j < adaptor->num_subpictures; j++) {
if (surface->compatible_subpictures->xvimage_ids[i] ==
@ -570,38 +556,50 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!pImage)
return BadImplementation;
info.id = pImage->id;
info.type = pImage->type;
info.byte_order = pImage->byte_order;
memcpy(&info.guid, pImage->guid, 16);
info.bpp = pImage->bits_per_pixel;
info.num_planes = pImage->num_planes;
info.depth = pImage->depth;
info.red_mask = pImage->red_mask;
info.green_mask = pImage->green_mask;
info.blue_mask = pImage->blue_mask;
info.format = pImage->format;
info.y_sample_bits = pImage->y_sample_bits;
info.u_sample_bits = pImage->u_sample_bits;
info.v_sample_bits = pImage->v_sample_bits;
info.horz_y_period = pImage->horz_y_period;
info.horz_u_period = pImage->horz_u_period;
info.horz_v_period = pImage->horz_v_period;
info.vert_y_period = pImage->vert_y_period;
info.vert_u_period = pImage->vert_u_period;
info.vert_v_period = pImage->vert_v_period;
memcpy(&info.comp_order, pImage->component_order, 32);
info.scanline_order = pImage->scanline_order;
WriteToClient(client, sizeof(xvImageFormatInfo), &info);
info[i].id = pImage->id;
info[i].type = pImage->type;
info[i].byte_order = pImage->byte_order;
memcpy(&info[i].guid, pImage->guid, 16);
info[i].bpp = pImage->bits_per_pixel;
info[i].num_planes = pImage->num_planes;
info[i].depth = pImage->depth;
info[i].red_mask = pImage->red_mask;
info[i].green_mask = pImage->green_mask;
info[i].blue_mask = pImage->blue_mask;
info[i].format = pImage->format;
info[i].y_sample_bits = pImage->y_sample_bits;
info[i].u_sample_bits = pImage->u_sample_bits;
info[i].v_sample_bits = pImage->v_sample_bits;
info[i].horz_y_period = pImage->horz_y_period;
info[i].horz_u_period = pImage->horz_u_period;
info[i].horz_v_period = pImage->horz_v_period;
info[i].vert_y_period = pImage->vert_y_period;
info[i].vert_u_period = pImage->vert_u_period;
info[i].vert_v_period = pImage->vert_v_period;
memcpy(&info[i].comp_order, pImage->component_order, 32);
info[i].scanline_order = pImage->scanline_order;
CLIENT_STRUCT_CARD32_5(&info[i], id, red_mask, green_mask, blue_mask, y_sample_bits);
CLIENT_STRUCT_CARD32_5(&info[i], u_sample_bits, v_sample_bits, horz_y_period, horz_u_period, horz_v_period);
CLIENT_STRUCT_CARD32_3(&info[i], vert_y_period, vert_u_period, vert_v_period);
}
xvmcListSubpictureTypesReply rep = {
.num = num,
};
REPLY_SEND_EXTRA(info, sizeof(info));
return Success;
}
static int
ProcXvMCGetDRInfo(ClientPtr client)
{
xvmcGetDRInfoReply rep;
REQUEST_HEAD_STRUCT(xvmcGetDRInfoReq);
REQUEST_FIELD_CARD32(port);
REQUEST_FIELD_CARD32(shmKey);
REQUEST_FIELD_CARD32(magic);
XvPortPtr pPort;
ScreenPtr pScreen;
XvMCScreenPtr pScreenPriv;
@ -610,29 +608,29 @@ ProcXvMCGetDRInfo(ClientPtr client)
volatile CARD32 *patternP;
#endif
REQUEST(xvmcGetDRInfoReq);
REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen);
rep = (xvmcGetDRInfoReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
int nameLen = strlen(pScreenPriv->clientDriverName) + 1;
int busIDLen = strlen(pScreenPriv->busID) + 1;
// buffer holds two zero-terminated strings, padded to 4-byte ints
char buf[pad_to_int32(nameLen+busIDLen)];
memset(buf, 0, sizeof(buf));
memcpy(buf, pScreenPriv->clientDriverName, nameLen);
memcpy(buf+nameLen, pScreenPriv->busID, busIDLen);
xvmcGetDRInfoReply rep = {
.major = pScreenPriv->major,
.minor = pScreenPriv->minor,
.patchLevel = pScreenPriv->patchLevel,
.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1),
.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1),
.nameLen = nameLen,
.busIDLen = busIDLen,
.isLocal = 1
};
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<= 2;
rep.busIDLen <<= 2;
/*
* Read back to the client what she has put in the shared memory
* segment she prepared for us.
@ -659,41 +657,45 @@ ProcXvMCGetDRInfo(ClientPtr client)
}
#endif /* HAS_XVMCSHM */
WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep);
if (rep.length) {
WriteToClient(client, rep.nameLen, pScreenPriv->clientDriverName);
WriteToClient(client, rep.busIDLen, pScreenPriv->busID);
}
REPLY_FIELD_CARD32(major);
REPLY_FIELD_CARD32(minor);
REPLY_FIELD_CARD32(patchLevel);
REPLY_FIELD_CARD32(nameLen);
REPLY_FIELD_CARD32(busIDLen);
REPLY_FIELD_CARD32(isLocal);
REPLY_SEND_EXTRA(buf, sizeof(buf));
return Success;
}
int (*ProcXvMCVector[xvmcNumRequest]) (ClientPtr) = {
ProcXvMCQueryVersion,
ProcXvMCListSurfaceTypes,
ProcXvMCCreateContext,
ProcXvMCDestroyContext,
ProcXvMCCreateSurface,
ProcXvMCDestroySurface,
ProcXvMCCreateSubpicture,
ProcXvMCDestroySubpicture,
ProcXvMCListSubpictureTypes, ProcXvMCGetDRInfo};
static int
ProcXvMCDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < xvmcNumRequest)
return (*ProcXvMCVector[stuff->data]) (client);
else
return BadRequest;
}
static int _X_COLD
SProcXvMCDispatch(ClientPtr client)
{
/* We only support local */
return BadImplementation;
switch (stuff->data)
{
case xvmc_QueryVersion:
return ProcXvMCQueryVersion(client);
case xvmc_ListSurfaceTypes:
return ProcXvMCListSurfaceTypes(client);
case xvmc_CreateContext:
return ProcXvMCCreateContext(client);
case xvmc_DestroyContext:
return ProcXvMCDestroyContext(client);
case xvmc_CreateSurface:
return ProcXvMCCreateSurface(client);
case xvmc_DestroySurface:
return ProcXvMCDestroySurface(client);
case xvmc_CreateSubpicture:
return ProcXvMCCreateSubpicture(client);
case xvmc_DestroySubpicture:
return ProcXvMCDestroySubpicture(client);
case xvmc_ListSubpictureTypes:
return ProcXvMCListSubpictureTypes(client);
case xvmc_GetDRInfo:
return ProcXvMCGetDRInfo(client);
default:
return BadRequest;
}
}
void
@ -717,7 +719,7 @@ XvMCExtensionInit(void)
return;
extEntry = AddExtension(XvMCName, XvMCNumEvents, XvMCNumErrors,
ProcXvMCDispatch, SProcXvMCDispatch,
ProcXvMCDispatch, ProcXvMCDispatch,
NULL, StandardMinorOpcode);
if (!extEntry)

View File

@ -58,25 +58,11 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "exglobals.h"
#include "allowev.h"
/***********************************************************************
*
* This procedure allows frozen events to be routed.
*
*/
int _X_COLD
SProcXAllowDeviceEvents(ClientPtr client)
{
REQUEST(xAllowDeviceEventsReq);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
swapl(&stuff->time);
return (ProcXAllowDeviceEvents(client));
}
/***********************************************************************
*
* This procedure allows frozen events to be routed.
@ -90,8 +76,8 @@ ProcXAllowDeviceEvents(ClientPtr client)
DeviceIntPtr thisdev;
int rc;
REQUEST(xAllowDeviceEventsReq);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
REQUEST_HEAD_STRUCT(xAllowDeviceEventsReq);
REQUEST_FIELD_CARD32(time);
rc = dixLookupDevice(&thisdev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef ALLOWEV_H
#define ALLOWEV_H 1
int SProcXAllowDeviceEvents(ClientPtr /* client */
);
int ProcXAllowDeviceEvents(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -64,37 +65,6 @@ SOFTWARE.
#include "exglobals.h"
#include "chgdctl.h"
/***********************************************************************
*
* This procedure changes the control attributes for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int _X_COLD
SProcXChangeDeviceControl(ClientPtr client)
{
xDeviceCtl *ctl;
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
swaps(&stuff->control);
ctl = (xDeviceCtl *) &stuff[1];
swaps(&ctl->control);
swaps(&ctl->length);
switch (stuff->control) {
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
case DEVICE_CORE:
case DEVICE_ENABLE:
case DEVICE_RESOLUTION:
/* hmm. beer. *drool* */
break;
}
return (ProcXChangeDeviceControl(client));
}
/***********************************************************************
*
* Change the control attributes.
@ -104,6 +74,11 @@ SProcXChangeDeviceControl(ClientPtr client)
int
ProcXChangeDeviceControl(ClientPtr client)
{
REQUEST_HEAD_AT_LEAST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
REQUEST_FIELD_CARD16(control);
CLIENT_STRUCT_CARD16_2((xDeviceCtl*)&stuff[1], control, length);
unsigned len;
int i, status, ret = BadValue;
DeviceIntPtr dev;
@ -112,9 +87,6 @@ ProcXChangeDeviceControl(ClientPtr client)
CARD32 *resolution;
xDeviceEnableCtl *e;
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
len = client->req_len - bytes_to_int32(sizeof(xChangeDeviceControlReq));
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
@ -127,9 +99,7 @@ ProcXChangeDeviceControl(ClientPtr client)
}
xChangeDeviceControlReply rep = {
.repType = X_Reply,
.RepType = X_ChangeDeviceControl,
.sequenceNumber = client->sequence,
.status = Success,
};
@ -231,10 +201,7 @@ ProcXChangeDeviceControl(ClientPtr client)
SendEventToAllWindows(dev, DevicePresenceNotifyMask,
(xEvent *) &dpn, 1);
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xChangeDeviceControlReply), &rep);
REPLY_SEND();
}
return ret;

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGDCTL_H
#define CHGDCTL_H 1
int SProcXChangeDeviceControl(ClientPtr /* client */
);
int ProcXChangeDeviceControl(ClientPtr /* client */
);

View File

@ -52,32 +52,18 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "chgfctl.h"
#define DO_ALL (-1)
/***********************************************************************
*
* This procedure changes the control attributes for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int _X_COLD
SProcXChangeFeedbackControl(ClientPtr client)
{
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
swapl(&stuff->mask);
return (ProcXChangeFeedbackControl(client));
}
/******************************************************************************
*
* This procedure changes KbdFeedbackClass data.
@ -92,13 +78,8 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
int t;
int key = DO_ALL;
if (client->swapped) {
swaps(&f->length);
swaps(&f->pitch);
swaps(&f->duration);
swapl(&f->led_mask);
swapl(&f->led_values);
}
CLIENT_STRUCT_CARD16_3(f, length, pitch, duration);
CLIENT_STRUCT_CARD32_2(f, led_mask, led_values);
kctrl = k->ctrl;
if (mask & DvKeyClickPercent) {
@ -209,12 +190,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
{
PtrCtrl pctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swaps(&f->num);
swaps(&f->denom);
swaps(&f->thresh);
}
CLIENT_STRUCT_CARD16_4(f, length, num, denom, thresh);
pctrl = p->ctrl;
if (mask & DvAccelNum) {
@ -275,10 +251,8 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
long unsigned int mask, IntegerFeedbackPtr i,
xIntegerFeedbackCtl * f)
{
if (client->swapped) {
swaps(&f->length);
swapl(&f->int_to_display);
}
CLIENT_STRUCT_CARD16_1(f, length);
CLIENT_STRUCT_CARD32_1(f, int_to_display);
i->ctrl.integer_displayed = f->int_to_display;
(*i->CtrlProc) (dev, &i->ctrl);
@ -300,10 +274,9 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
KeySym *syms, *sup_syms;
syms = (KeySym *) (f + 1);
if (client->swapped) {
swaps(&f->length); /* swapped num_keysyms in calling proc */
SwapLongs((CARD32 *) syms, f->num_keysyms);
}
CLIENT_STRUCT_CARD16_1(f, length); /* swapped num_keysyms in calling proc */
REQUEST_BUF_CARD32((CARD32 *) syms, f->num_keysyms);
if (f->num_keysyms > s->ctrl.max_symbols)
return BadValue;
@ -338,11 +311,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
int t;
BellCtrl bctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swaps(&f->pitch);
swaps(&f->duration);
}
CLIENT_STRUCT_CARD16_3(f, length, pitch, duration);
bctrl = b->ctrl;
if (mask & DvPercent) {
@ -394,11 +363,8 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
{
LedCtrl lctrl; /* might get BadValue part way through */
if (client->swapped) {
swaps(&f->length);
swapl(&f->led_values);
swapl(&f->led_mask);
}
CLIENT_STRUCT_CARD16_1(f, length);
CLIENT_STRUCT_CARD32_2(f, led_values, led_mask);
f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
f->led_values &= l->ctrl.led_mask; /* set only supported leds */
@ -432,8 +398,8 @@ ProcXChangeFeedbackControl(ClientPtr client)
LedFeedbackPtr l;
int rc;
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
REQUEST_HEAD_AT_LEAST(xChangeFeedbackControlReq);
REQUEST_FIELD_CARD32(mask);
len = client->req_len - bytes_to_int32(sizeof(xChangeFeedbackControlReq));
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
@ -466,11 +432,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeFeedbackControlReq,
sizeof(xStringFeedbackCtl));
f = ((xStringFeedbackCtl *) &stuff[1]);
if (client->swapped) {
if (len < bytes_to_int32(sizeof(xStringFeedbackCtl)))
return BadLength;
swaps(&f->num_keysyms);
}
CLIENT_STRUCT_CARD16_1(f, num_keysyms);
if (len !=
(bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
return BadLength;

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGFCTL_H
#define CHGFCTL_H 1
int SProcXChangeFeedbackControl(ClientPtr /* client */
);
int ProcXChangeFeedbackControl(ClientPtr /* client */
);

View File

@ -52,12 +52,14 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"
#include "globals.h"
#include "exevents.h"
#include "exglobals.h"
@ -72,8 +74,7 @@ SOFTWARE.
int
ProcXChangeKeyboardDevice(ClientPtr client)
{
/* REQUEST(xChangeKeyboardDeviceReq); */
REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
REQUEST_HEAD_STRUCT(xChangeKeyboardDeviceReq);
return BadDevice;
}

View File

@ -56,32 +56,13 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "chgkmap.h"
/***********************************************************************
*
* This procedure swaps the request when the client and
* server have different byte orderings.
*
*/
int _X_COLD
SProcXChangeDeviceKeyMapping(ClientPtr client)
{
unsigned int count;
REQUEST(xChangeDeviceKeyMappingReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
count = stuff->keyCodes * stuff->keySymsPerKeyCode;
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), count);
return (ProcXChangeDeviceKeyMapping(client));
}
/***********************************************************************
*
* Change the device key mapping.
@ -96,11 +77,10 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
DeviceIntPtr dev;
unsigned int count;
REQUEST(xChangeDeviceKeyMappingReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
REQUEST_HEAD_AT_LEAST(xChangeDeviceKeyMappingReq);
count = stuff->keyCodes * stuff->keySymsPerKeyCode;
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
REQUEST_BUF_CARD32(&stuff[1], count);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGKMAP_H
#define CHGKMAP_H 1
int SProcXChangeDeviceKeyMapping(ClientPtr /* client */
);
int ProcXChangeDeviceKeyMapping(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h"
@ -65,25 +66,6 @@ SOFTWARE.
#include "chgprop.h"
#include "grabdev.h"
/***********************************************************************
*
* This procedure returns the extension version.
*
*/
int _X_COLD
SProcXChangeDeviceDontPropagateList(ClientPtr client)
{
REQUEST(xChangeDeviceDontPropagateListReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
swapl(&stuff->window);
swaps(&stuff->count);
REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq,
stuff->count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
return (ProcXChangeDeviceDontPropagateList(client));
}
/***********************************************************************
*
* This procedure changes the dont-propagate list for the specified window.
@ -98,13 +80,12 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
struct tmask tmp[EMASKSIZE];
OtherInputMasks *others;
REQUEST(xChangeDeviceDontPropagateListReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
if (client->req_len !=
bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) +
stuff->count)
return BadLength;
REQUEST_HEAD_AT_LEAST(xChangeDeviceDontPropagateListReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD16(count);
REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq,
stuff->count * sizeof(CARD32));
REQUEST_BUF_CARD32(&stuff[1], stuff->count);
rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
if (rc != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef CHGPROP_H
#define CHGPROP_H 1
int SProcXChangeDeviceDontPropagateList(ClientPtr /* client */
);
int ProcXChangeDeviceDontPropagateList(ClientPtr /* client */
);

View File

@ -52,13 +52,15 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include "exevents.h"
#include "exglobals.h"
@ -73,8 +75,7 @@ SOFTWARE.
int
ProcXChangePointerDevice(ClientPtr client)
{
/* REQUEST(xChangePointerDeviceReq); */
REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
REQUEST_HEAD_STRUCT(xChangePointerDeviceReq);
return BadDevice;
}

View File

@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -125,8 +126,7 @@ ProcXCloseDevice(ClientPtr client)
WindowPtr pWin, p1;
DeviceIntPtr d;
REQUEST(xCloseDeviceReq);
REQUEST_SIZE_MATCH(xCloseDeviceReq);
REQUEST_HEAD_STRUCT(xCloseDeviceReq);
rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess);
if (rc != Success)

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "devbell.h"
@ -77,8 +80,7 @@ ProcXDeviceBell(ClientPtr client)
void *ctrl;
BellProcPtr proc;
REQUEST(xDeviceBellReq);
REQUEST_SIZE_MATCH(xDeviceBellReq);
REQUEST_HEAD_STRUCT(xDeviceBellReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess);
if (rc != Success) {

View File

@ -181,143 +181,6 @@ XExtEventInfo EventInfo[32];
static DeviceIntRec xi_all_devices;
static DeviceIntRec xi_all_master_devices;
/**
* Dispatch vector. Functions defined in here will be called when the matching
* request arrives.
*/
static int (*ProcIVector[]) (ClientPtr) = {
NULL, /* 0 */
ProcXGetExtensionVersion, /* 1 */
ProcXListInputDevices, /* 2 */
ProcXOpenDevice, /* 3 */
ProcXCloseDevice, /* 4 */
ProcXSetDeviceMode, /* 5 */
ProcXSelectExtensionEvent, /* 6 */
ProcXGetSelectedExtensionEvents, /* 7 */
ProcXChangeDeviceDontPropagateList, /* 8 */
ProcXGetDeviceDontPropagateList, /* 9 */
ProcXGetDeviceMotionEvents, /* 10 */
ProcXChangeKeyboardDevice, /* 11 */
ProcXChangePointerDevice, /* 12 */
ProcXGrabDevice, /* 13 */
ProcXUngrabDevice, /* 14 */
ProcXGrabDeviceKey, /* 15 */
ProcXUngrabDeviceKey, /* 16 */
ProcXGrabDeviceButton, /* 17 */
ProcXUngrabDeviceButton, /* 18 */
ProcXAllowDeviceEvents, /* 19 */
ProcXGetDeviceFocus, /* 20 */
ProcXSetDeviceFocus, /* 21 */
ProcXGetFeedbackControl, /* 22 */
ProcXChangeFeedbackControl, /* 23 */
ProcXGetDeviceKeyMapping, /* 24 */
ProcXChangeDeviceKeyMapping, /* 25 */
ProcXGetDeviceModifierMapping, /* 26 */
ProcXSetDeviceModifierMapping, /* 27 */
ProcXGetDeviceButtonMapping, /* 28 */
ProcXSetDeviceButtonMapping, /* 29 */
ProcXQueryDeviceState, /* 30 */
ProcXSendExtensionEvent, /* 31 */
ProcXDeviceBell, /* 32 */
ProcXSetDeviceValuators, /* 33 */
ProcXGetDeviceControl, /* 34 */
ProcXChangeDeviceControl, /* 35 */
/* XI 1.5 */
ProcXListDeviceProperties, /* 36 */
ProcXChangeDeviceProperty, /* 37 */
ProcXDeleteDeviceProperty, /* 38 */
ProcXGetDeviceProperty, /* 39 */
/* XI 2 */
ProcXIQueryPointer, /* 40 */
ProcXIWarpPointer, /* 41 */
ProcXIChangeCursor, /* 42 */
ProcXIChangeHierarchy, /* 43 */
ProcXISetClientPointer, /* 44 */
ProcXIGetClientPointer, /* 45 */
ProcXISelectEvents, /* 46 */
ProcXIQueryVersion, /* 47 */
ProcXIQueryDevice, /* 48 */
ProcXISetFocus, /* 49 */
ProcXIGetFocus, /* 50 */
ProcXIGrabDevice, /* 51 */
ProcXIUngrabDevice, /* 52 */
ProcXIAllowEvents, /* 53 */
ProcXIPassiveGrabDevice, /* 54 */
ProcXIPassiveUngrabDevice, /* 55 */
ProcXIListProperties, /* 56 */
ProcXIChangeProperty, /* 57 */
ProcXIDeleteProperty, /* 58 */
ProcXIGetProperty, /* 59 */
ProcXIGetSelectedEvents, /* 60 */
ProcXIBarrierReleasePointer /* 61 */
};
/* For swapped clients */
static int (*SProcIVector[]) (ClientPtr) = {
NULL, /* 0 */
SProcXGetExtensionVersion, /* 1 */
ProcXListInputDevices, /* 2 */
ProcXOpenDevice, /* 3 */
ProcXCloseDevice, /* 4 */
ProcXSetDeviceMode, /* 5 */
SProcXSelectExtensionEvent, /* 6 */
SProcXGetSelectedExtensionEvents, /* 7 */
SProcXChangeDeviceDontPropagateList, /* 8 */
SProcXGetDeviceDontPropagateList, /* 9 */
SProcXGetDeviceMotionEvents, /* 10 */
ProcXChangeKeyboardDevice, /* 11 */
ProcXChangePointerDevice, /* 12 */
SProcXGrabDevice, /* 13 */
SProcXUngrabDevice, /* 14 */
SProcXGrabDeviceKey, /* 15 */
SProcXUngrabDeviceKey, /* 16 */
SProcXGrabDeviceButton, /* 17 */
SProcXUngrabDeviceButton, /* 18 */
SProcXAllowDeviceEvents, /* 19 */
ProcXGetDeviceFocus, /* 20 */
SProcXSetDeviceFocus, /* 21 */
ProcXGetFeedbackControl, /* 22 */
SProcXChangeFeedbackControl, /* 23 */
ProcXGetDeviceKeyMapping, /* 24 */
SProcXChangeDeviceKeyMapping, /* 25 */
ProcXGetDeviceModifierMapping, /* 26 */
ProcXSetDeviceModifierMapping, /* 27 */
ProcXGetDeviceButtonMapping, /* 28 */
ProcXSetDeviceButtonMapping, /* 29 */
ProcXQueryDeviceState, /* 30 */
SProcXSendExtensionEvent, /* 31 */
ProcXDeviceBell, /* 32 */
ProcXSetDeviceValuators, /* 33 */
SProcXGetDeviceControl, /* 34 */
SProcXChangeDeviceControl, /* 35 */
ProcXListDeviceProperties, /* 36 */
SProcXChangeDeviceProperty, /* 37 */
SProcXDeleteDeviceProperty, /* 38 */
SProcXGetDeviceProperty, /* 39 */
SProcXIQueryPointer, /* 40 */
SProcXIWarpPointer, /* 41 */
SProcXIChangeCursor, /* 42 */
ProcXIChangeHierarchy, /* 43 */
SProcXISetClientPointer, /* 44 */
SProcXIGetClientPointer, /* 45 */
SProcXISelectEvents, /* 46 */
SProcXIQueryVersion, /* 47 */
SProcXIQueryDevice, /* 48 */
SProcXISetFocus, /* 49 */
SProcXIGetFocus, /* 50 */
SProcXIGrabDevice, /* 51 */
SProcXIUngrabDevice, /* 52 */
SProcXIAllowEvents, /* 53 */
SProcXIPassiveGrabDevice, /* 54 */
SProcXIPassiveUngrabDevice, /* 55 */
SProcXIListProperties, /* 56 */
SProcXIChangeProperty, /* 57 */
SProcXIDeleteProperty, /* 58 */
SProcXIGetProperty, /* 59 */
SProcXIGetSelectedEvents, /* 60 */
SProcXIBarrierReleasePointer /* 61 */
};
/*****************************************************************
*
* Globals referenced elsewhere in the server.
@ -384,31 +247,137 @@ static int
ProcIDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
return BadRequest;
UpdateCurrentTimeIf();
return (*ProcIVector[stuff->data]) (client);
}
/*******************************************************************************
*
* SProcXDispatch
*
* Main swapped dispatch routine for requests to this extension.
* This routine is used if server and client do not have the same byte ordering.
*
*/
static int _X_COLD
SProcIDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
return BadRequest;
UpdateCurrentTimeIf();
return (*SProcIVector[stuff->data]) (client);
switch (stuff->data) {
case X_GetExtensionVersion:
return ProcXGetExtensionVersion(client);
case X_ListInputDevices:
return ProcXListInputDevices(client);
case X_OpenDevice:
return ProcXOpenDevice(client);
case X_CloseDevice:
return ProcXCloseDevice(client);
case X_SetDeviceMode:
return ProcXSetDeviceMode(client);
case X_SelectExtensionEvent:
return ProcXSelectExtensionEvent(client);
case X_GetSelectedExtensionEvents:
return ProcXGetSelectedExtensionEvents(client);
case X_ChangeDeviceDontPropagateList:
return ProcXChangeDeviceDontPropagateList(client);
case X_GetDeviceDontPropagateList:
return ProcXGetDeviceDontPropagateList(client);
case X_GetDeviceMotionEvents:
return ProcXGetDeviceMotionEvents(client);
case X_ChangeKeyboardDevice:
return ProcXChangeKeyboardDevice(client);
case X_ChangePointerDevice:
return ProcXChangePointerDevice(client);
case X_GrabDevice:
return ProcXGrabDevice(client);
case X_UngrabDevice:
return ProcXUngrabDevice(client);
case X_GrabDeviceKey:
return ProcXGrabDeviceKey(client);
case X_UngrabDeviceKey:
return ProcXUngrabDeviceKey(client);
case X_GrabDeviceButton:
return ProcXGrabDeviceButton(client);
case X_UngrabDeviceButton:
return ProcXUngrabDeviceButton(client);
case X_AllowDeviceEvents:
return ProcXAllowDeviceEvents(client);
case X_GetDeviceFocus:
return ProcXGetDeviceFocus(client);
case X_SetDeviceFocus:
return ProcXSetDeviceFocus(client);
case X_GetFeedbackControl:
return ProcXGetFeedbackControl(client);
case X_ChangeFeedbackControl:
return ProcXChangeFeedbackControl(client);
case X_GetDeviceKeyMapping:
return ProcXGetDeviceKeyMapping(client);
case X_ChangeDeviceKeyMapping:
return ProcXChangeDeviceKeyMapping(client);
case X_GetDeviceModifierMapping:
return ProcXGetDeviceModifierMapping(client);
case X_SetDeviceModifierMapping:
return ProcXSetDeviceModifierMapping(client);
case X_GetDeviceButtonMapping:
return ProcXGetDeviceButtonMapping(client);
case X_SetDeviceButtonMapping:
return ProcXSetDeviceButtonMapping(client);
case X_QueryDeviceState:
return ProcXQueryDeviceState(client);
case X_SendExtensionEvent:
return ProcXSendExtensionEvent(client);
case X_DeviceBell:
return ProcXDeviceBell(client);
case X_SetDeviceValuators:
return ProcXSetDeviceValuators(client);
case X_GetDeviceControl:
return ProcXGetDeviceControl(client);
case X_ChangeDeviceControl:
return ProcXChangeDeviceControl(client);
/* XI 1.5 */
case X_ListDeviceProperties:
return ProcXListDeviceProperties(client);
case X_ChangeDeviceProperty:
return ProcXChangeDeviceProperty(client);
case X_DeleteDeviceProperty:
return ProcXDeleteDeviceProperty(client);
case X_GetDeviceProperty:
return ProcXGetDeviceProperty(client);
/* XI 2 */
case X_XIQueryPointer:
return ProcXIQueryPointer(client);
case X_XIWarpPointer:
return ProcXIWarpPointer(client);
case X_XIChangeCursor:
return ProcXIChangeCursor(client);
case X_XIChangeHierarchy:
return ProcXIChangeHierarchy(client);
case X_XISetClientPointer:
return ProcXISetClientPointer(client);
case X_XIGetClientPointer:
return ProcXIGetClientPointer(client);
case X_XISelectEvents:
return ProcXISelectEvents(client);
case X_XIQueryVersion:
return ProcXIQueryVersion(client);
case X_XIQueryDevice:
return ProcXIQueryDevice(client);
case X_XISetFocus:
return ProcXISetFocus(client);
case X_XIGetFocus:
return ProcXIGetFocus(client);
case X_XIGrabDevice:
return ProcXIGrabDevice(client);
case X_XIUngrabDevice:
return ProcXIUngrabDevice(client);
case X_XIAllowEvents:
return ProcXIAllowEvents(client);
case X_XIPassiveGrabDevice:
return ProcXIPassiveGrabDevice(client);
case X_XIPassiveUngrabDevice:
return ProcXIPassiveUngrabDevice(client);
case X_XIListProperties:
return ProcXIListProperties(client);
case X_XIChangeProperty:
return ProcXIChangeProperty(client);
case X_XIDeleteProperty:
return ProcXIDeleteProperty(client);
case X_XIGetProperty:
return ProcXIGetProperty(client);
case X_XIGetSelectedEvents:
return ProcXIGetSelectedEvents(client);
case X_XIBarrierReleasePointer:
return ProcXIBarrierReleasePointer(client);
default:
return BadRequest;
}
}
/************************************************************************
@ -1229,7 +1198,7 @@ XInputExtensionInit(void)
FatalError("Could not initialize barriers.\n");
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
SProcIDispatch, IResetProc, StandardMinorOpcode);
ProcIDispatch, IResetProc, StandardMinorOpcode);
if (extEntry) {
assert(extEntry->base == EXTENSION_MAJOR_XINPUT);

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "getbmap.h"
@ -72,8 +75,7 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
ButtonClassPtr b;
int rc;
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
REQUEST_HEAD_STRUCT(xGetDeviceButtonMappingReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
@ -84,18 +86,11 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
return BadMatch;
xGetDeviceButtonMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceButtonMapping,
.sequenceNumber = client->sequence,
.nElts = b->numButtons,
.length = bytes_to_int32(b->numButtons),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts, &b->map[1]);
REPLY_SEND_EXTRA(&b->map[1], rep.nElts);
return Success;
}

View File

@ -52,29 +52,16 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "getdctl.h"
/***********************************************************************
*
* This procedure gets the control attributes for an extension device,
* for clients on machines with a different byte ordering than the server.
*
*/
int _X_COLD
SProcXGetDeviceControl(ClientPtr client)
{
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
swaps(&stuff->control);
return (ProcXGetDeviceControl(client));
}
/***********************************************************************
*
* This procedure copies DeviceResolution data, swapping if necessary.
@ -101,15 +88,10 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
*iptr++ = a->min_resolution;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->max_resolution;
if (client->swapped) {
swaps(&r->control);
swaps(&r->length);
swapl(&r->num_valuators);
iptr = (int *) buf;
for (i = 0; i < (3 * v->numAxes); i++, iptr++) {
swapl(iptr);
}
}
CLIENT_STRUCT_CARD16_2(r, control, length);
CLIENT_STRUCT_CARD32_1(r, num_valuators);
REPLY_BUF_CARD32(buf, (3 * v->numAxes));
}
static void
@ -122,10 +104,7 @@ CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf)
c->status = dev->coreEvents;
c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer);
if (client->swapped) {
swaps(&c->control);
swaps(&c->length);
}
CLIENT_STRUCT_CARD16_2(c, control, length);
}
static void
@ -137,10 +116,7 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf)
e->length = sizeof(xDeviceEnableState);
e->enable = dev->enabled;
if (client->swapped) {
swaps(&e->control);
swaps(&e->length);
}
CLIENT_STRUCT_CARD16_2(e, control, length);
}
/***********************************************************************
@ -153,11 +129,10 @@ int
ProcXGetDeviceControl(ClientPtr client)
{
int rc, total_length = 0;
char *savbuf;
DeviceIntPtr dev;
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
REQUEST_HEAD_STRUCT(xGetDeviceControlReq);
REQUEST_FIELD_CARD16(control);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
@ -186,7 +161,7 @@ ProcXGetDeviceControl(ClientPtr client)
char *buf = calloc(1, total_length);
if (!buf)
return BadAlloc;
savbuf = buf;
char *savbuf = buf;
switch (stuff->control) {
case DEVICE_RESOLUTION:
@ -203,18 +178,10 @@ ProcXGetDeviceControl(ClientPtr client)
}
xGetDeviceControlReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceControl,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(total_length),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xGetDeviceControlReply), &rep);
WriteToClient(client, total_length, savbuf);
REPLY_SEND_EXTRA(buf, total_length);
free(savbuf);
return Success;
}

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETDCTL_H
#define GETDCTL_H 1
int SProcXGetDeviceControl(ClientPtr /* client */
);
int ProcXGetDeviceControl(ClientPtr /* client */
);

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "getfctl.h"
@ -83,13 +86,10 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
k2->global_auto_repeat = k->ctrl.autoRepeat;
for (i = 0; i < 32; i++)
k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
if (client->swapped) {
swaps(&k2->length);
swaps(&k2->pitch);
swaps(&k2->duration);
swapl(&k2->led_mask);
swapl(&k2->led_values);
}
CLIENT_STRUCT_CARD16_3(k2, length, pitch, duration);
CLIENT_STRUCT_CARD32_2(k2, led_mask, led_values);
*buf += sizeof(xKbdFeedbackState);
}
@ -111,12 +111,9 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
p2->accelNum = p->ctrl.num;
p2->accelDenom = p->ctrl.den;
p2->threshold = p->ctrl.threshold;
if (client->swapped) {
swaps(&p2->length);
swaps(&p2->accelNum);
swaps(&p2->accelDenom);
swaps(&p2->threshold);
}
CLIENT_STRUCT_CARD16_4(p2, length, accelNum, accelDenom, threshold);
*buf += sizeof(xPtrFeedbackState);
}
@ -138,12 +135,10 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
i2->resolution = i->ctrl.resolution;
i2->min_value = i->ctrl.min_value;
i2->max_value = i->ctrl.max_value;
if (client->swapped) {
swaps(&i2->length);
swapl(&i2->resolution);
swapl(&i2->min_value);
swapl(&i2->max_value);
}
CLIENT_STRUCT_CARD16_1(i2, length);
CLIENT_STRUCT_CARD32_3(i2, resolution, min_value, max_value);
*buf += sizeof(xIntegerFeedbackState);
}
@ -171,15 +166,10 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++)
*kptr++ = *(s->ctrl.symbols_supported + i);
if (client->swapped) {
swaps(&s2->length);
swaps(&s2->max_symbols);
swaps(&s2->num_syms_supported);
kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) {
swapl(kptr);
}
}
CLIENT_STRUCT_CARD16_3(s2, length, max_symbols, num_syms_supported);
REPLY_BUF_CARD32((CARD32*)buf, s->ctrl.num_symbols_supported);
*buf += (s->ctrl.num_symbols_supported * sizeof(KeySym));
}
@ -200,11 +190,10 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
l2->id = l->ctrl.id;
l2->led_values = l->ctrl.led_values;
l2->led_mask = l->ctrl.led_mask;
if (client->swapped) {
swaps(&l2->length);
swapl(&l2->led_values);
swapl(&l2->led_mask);
}
CLIENT_STRUCT_CARD16_1(l2, length);
CLIENT_STRUCT_CARD32_2(l2, led_values, led_mask);
*buf += sizeof(xLedFeedbackState);
}
@ -226,11 +215,9 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
b2->percent = b->ctrl.percent;
b2->pitch = b->ctrl.pitch;
b2->duration = b->ctrl.duration;
if (client->swapped) {
swaps(&b2->length);
swaps(&b2->pitch);
swaps(&b2->duration);
}
CLIENT_STRUCT_CARD16_3(b2, length, pitch, duration);
*buf += sizeof(xBellFeedbackState);
}
@ -244,7 +231,6 @@ int
ProcXGetFeedbackControl(ClientPtr client)
{
int rc, total_length = 0;
char *savbuf;
DeviceIntPtr dev;
KbdFeedbackPtr k;
PtrFeedbackPtr p;
@ -253,18 +239,14 @@ ProcXGetFeedbackControl(ClientPtr client)
BellFeedbackPtr b;
LedFeedbackPtr l;
REQUEST(xGetFeedbackControlReq);
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
REQUEST_HEAD_STRUCT(xGetFeedbackControlReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
xGetFeedbackControlReply rep = {
.repType = X_Reply,
.RepType = X_GetFeedbackControl,
.sequenceNumber = client->sequence,
.num_feedbacks = 0
};
for (k = dev->kbdfeed; k; k = k->next) {
@ -299,7 +281,7 @@ ProcXGetFeedbackControl(ClientPtr client)
char *buf = (char *) calloc(1, total_length);
if (!buf)
return BadAlloc;
savbuf = buf;
char *savbuf = buf;
for (k = dev->kbdfeed; k; k = k->next)
CopySwapKbdFeedback(client, k, &buf);
@ -314,15 +296,7 @@ ProcXGetFeedbackControl(ClientPtr client)
for (b = dev->bell; b; b = b->next)
CopySwapBellFeedback(client, b, &buf);
rep.length = bytes_to_int32(total_length);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_feedbacks);
}
WriteToClient(client, sizeof(xGetFeedbackControlReply), &rep);
WriteToClient(client, total_length, savbuf);
free(savbuf);
REPLY_FIELD_CARD16(num_feedbacks);
REPLY_SEND_EXTRA(savbuf, total_length);
return Success;
}

View File

@ -52,10 +52,13 @@ SOFTWARE.
#include <dix-config.h>
#include "windowstr.h" /* focus struct */
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "windowstr.h" /* focus struct */
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "getfocus.h"
@ -73,8 +76,7 @@ ProcXGetDeviceFocus(ClientPtr client)
FocusClassPtr focus;
int rc;
REQUEST(xGetDeviceFocusReq);
REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
REQUEST_HEAD_STRUCT(xGetDeviceFocusReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetFocusAccess);
if (rc != Success)
@ -82,15 +84,14 @@ ProcXGetDeviceFocus(ClientPtr client)
if (!dev->focus)
return BadDevice;
xGetDeviceFocusReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceFocus,
.sequenceNumber = client->sequence,
.length = 0
};
focus = dev->focus;
xGetDeviceFocusReply rep = {
.RepType = X_GetDeviceFocus,
.time = focus->time.milliseconds,
.revertTo = focus->revert,
};
if (focus->win == NoneWin)
rep.focus = None;
else if (focus->win == PointerRootWin)
@ -100,15 +101,8 @@ ProcXGetDeviceFocus(ClientPtr client)
else
rep.focus = focus->win->drawable.id;
rep.time = focus->time.milliseconds;
rep.revertTo = focus->revert;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.focus);
swapl(&rep.time);
}
WriteToClient(client, sizeof(xGetDeviceFocusReply), &rep);
REPLY_FIELD_CARD32(focus);
REPLY_FIELD_CARD32(time);
REPLY_SEND();
return Success;
}

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "swaprep.h"
#include "xkbsrv.h"
@ -76,8 +79,7 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
KeySymsPtr syms;
int rc;
REQUEST(xGetDeviceKeyMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
REQUEST_HEAD_STRUCT(xGetDeviceKeyMappingReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
@ -102,18 +104,12 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
return BadAlloc;
xGetDeviceKeyMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceKeyMapping,
.sequenceNumber = client->sequence,
.keySymsPerKeyCode = syms->mapWidth,
.length = (syms->mapWidth * stuff->count) /* KeySyms are 4 bytes */
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
REPLY_SEND();
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
WriteSwappedDataToClient(client,

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* Request macro */
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "getmmap.h"
@ -72,8 +75,7 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
KeyCode *modkeymap = NULL;
int ret, max_keys_per_mod;
REQUEST(xGetDeviceModifierMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
REQUEST_HEAD_STRUCT(xGetDeviceModifierMappingReq);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)
@ -84,21 +86,12 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
return ret;
xGetDeviceModifierMappingReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceModifierMapping,
.sequenceNumber = client->sequence,
.numKeyPerModifier = max_keys_per_mod,
/* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
.length = max_keys_per_mod << 1
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep);
WriteToClient(client, max_keys_per_mod * 8, modkeymap);
/* 8 modifiers per key, each CARD8 */
REPLY_SEND_EXTRA(modkeymap, max_keys_per_mod * 8);
free(modkeymap);
return Success;

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structs */
@ -66,21 +67,6 @@ SOFTWARE.
extern XExtEventInfo EventInfo[];
extern int ExtEventIndex;
/***********************************************************************
*
* Handle a request from a client with a different byte order.
*
*/
int _X_COLD
SProcXGetDeviceDontPropagateList(ClientPtr client)
{
REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
swapl(&stuff->window);
return (ProcXGetDeviceDontPropagateList(client));
}
/***********************************************************************
*
* This procedure lists the input devices available to the server.
@ -96,15 +82,11 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
WindowPtr pWin;
OtherInputMasks *others;
REQUEST(xGetDeviceDontPropagateListReq);
REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
REQUEST_HEAD_STRUCT(xGetDeviceDontPropagateListReq);
REQUEST_FIELD_CARD32(window);
xGetDeviceDontPropagateListReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceDontPropagateList,
.sequenceNumber = client->sequence,
.length = 0,
.count = 0
};
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
@ -126,12 +108,8 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
}
}
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.count);
}
WriteToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep);
REPLY_FIELD_CARD16(count);
REPLY_SEND();
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETPROP_H
#define GETPROP_H 1
int SProcXGetDeviceDontPropagateList(ClientPtr /* client */
);
int ProcXGetDeviceDontPropagateList(ClientPtr /* client */
);

View File

@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -64,21 +65,6 @@ SOFTWARE.
#include "getprop.h"
#include "getselev.h"
/***********************************************************************
*
* This procedure gets the current selected extension events.
*
*/
int _X_COLD
SProcXGetSelectedExtensionEvents(ClientPtr client)
{
REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
swapl(&stuff->window);
return (ProcXGetSelectedExtensionEvents(client));
}
/***********************************************************************
*
* This procedure gets the current device select mask,
@ -97,16 +83,11 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
OtherInputMasks *pOthers;
InputClientsPtr others;
REQUEST(xGetSelectedExtensionEventsReq);
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
REQUEST_HEAD_STRUCT(xGetSelectedExtensionEventsReq);
REQUEST_FIELD_CARD32(window);
xGetSelectedExtensionEventsReply rep = {
.repType = X_Reply,
.RepType = X_GetSelectedExtensionEvents,
.sequenceNumber = client->sequence,
.length = 0,
.this_client_count = 0,
.all_clients_count = 0
};
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
@ -145,13 +126,9 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
ClassFromMask(aclient, others->mask[i], i, NULL, CREATE);
}
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.this_client_count);
swaps(&rep.all_clients_count);
}
WriteToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);
REPLY_FIELD_CARD16(this_client_count);
REPLY_FIELD_CARD16(all_clients_count);
REPLY_SEND();
if (total_length) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETSELEV_H
#define GETSELEV_H 1
int SProcXGetSelectedExtensionEvents(ClientPtr /* client */
);
int ProcXGetSelectedExtensionEvents(ClientPtr /* client */
);

View File

@ -52,9 +52,12 @@ SOFTWARE.
#include <dix-config.h>
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exevents.h"
#include "exglobals.h"
@ -62,21 +65,6 @@ SOFTWARE.
XExtensionVersion XIVersion;
/***********************************************************************
*
* Handle a request from a client with a different byte order than us.
*
*/
int _X_COLD
SProcXGetExtensionVersion(ClientPtr client)
{
REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
swaps(&stuff->nbytes);
return (ProcXGetExtensionVersion(client));
}
/***********************************************************************
*
* This procedure returns the major/minor version of the X Input extension.
@ -86,31 +74,22 @@ SProcXGetExtensionVersion(ClientPtr client)
int
ProcXGetExtensionVersion(ClientPtr client)
{
REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
REQUEST_HEAD_STRUCT(xGetExtensionVersionReq);
REQUEST_FIELD_CARD16(nbytes);
if (client->req_len != bytes_to_int32(sizeof(xGetExtensionVersionReq) +
stuff->nbytes))
return BadLength;
xGetExtensionVersionReply rep = {
.repType = X_Reply,
.RepType = X_GetExtensionVersion,
.sequenceNumber = client->sequence,
.length = 0,
.major_version = XIVersion.major_version,
.minor_version = XIVersion.minor_version,
.present = TRUE
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.major_version);
swaps(&rep.minor_version);
}
WriteToClient(client, sizeof(xGetExtensionVersionReply), &rep);
REPLY_FIELD_CARD16(major_version);
REPLY_FIELD_CARD16(minor_version);
REPLY_SEND();
return Success;
}

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GETVERS_H
#define GETVERS_H 1
int SProcXGetExtensionVersion(ClientPtr /* client */
);
int ProcXGetExtensionVersion(ClientPtr /* client */
);

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -65,31 +66,6 @@ SOFTWARE.
extern XExtEventInfo EventInfo[];
extern int ExtEventIndex;
/***********************************************************************
*
* Swap the request if the requestor has a different byte order than us.
*
*/
int _X_COLD
SProcXGrabDevice(ClientPtr client)
{
REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
swapl(&stuff->grabWindow);
swapl(&stuff->time);
swaps(&stuff->event_count);
if (client->req_len !=
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
return (ProcXGrabDevice(client));
}
/***********************************************************************
*
* Grab an extension device.
@ -104,18 +80,19 @@ ProcXGrabDevice(ClientPtr client)
GrabMask mask;
struct tmask tmp[EMASKSIZE];
REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
REQUEST_HEAD_AT_LEAST(xGrabDeviceReq);
REQUEST_FIELD_CARD32(grabWindow);
REQUEST_FIELD_CARD32(time);
REQUEST_FIELD_CARD16(event_count);
if (client->req_len !=
bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
REQUEST_BUF_CARD32(&stuff[1], stuff->event_count);
xGrabDeviceReply rep = {
.repType = X_Reply,
.RepType = X_GrabDevice,
.sequenceNumber = client->sequence,
.length = 0,
};
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
@ -137,11 +114,7 @@ ProcXGrabDevice(ClientPtr client)
if (rc != Success)
return rc;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xGrabDeviceReply), &rep);
REPLY_SEND();
return Success;
}

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GRABDEV_H
#define GRABDEV_H 1
int SProcXGrabDevice(ClientPtr /* client */
);
int ProcXGrabDevice(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -65,27 +66,6 @@ SOFTWARE.
#include "grabdev.h"
#include "grabdevb.h"
/***********************************************************************
*
* Handle requests from clients with a different byte order.
*
*/
int _X_COLD
SProcXGrabDeviceButton(ClientPtr client)
{
REQUEST(xGrabDeviceButtonReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swaps(&stuff->event_count);
REQUEST_FIXED_SIZE(xGrabDeviceButtonReq,
stuff->event_count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
return (ProcXGrabDeviceButton(client));
}
/***********************************************************************
*
* Grab a button on an extension device.
@ -100,15 +80,15 @@ ProcXGrabDeviceButton(ClientPtr client)
DeviceIntPtr mdev;
XEventClass *class;
struct tmask tmp[EMASKSIZE];
GrabParameters param;
GrabMask mask;
REQUEST(xGrabDeviceButtonReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
if (client->req_len !=
bytes_to_int32(sizeof(xGrabDeviceButtonReq)) + stuff->event_count)
return BadLength;
REQUEST_HEAD_AT_LEAST(xGrabDeviceButtonReq);
REQUEST_FIELD_CARD32(grabWindow);
REQUEST_FIELD_CARD16(modifiers);
REQUEST_FIELD_CARD16(event_count);
REQUEST_FIXED_SIZE(xGrabDeviceButtonReq,
stuff->event_count * sizeof(CARD32));
REQUEST_BUF_CARD32(&stuff[1], stuff->event_count);
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (ret != Success)
@ -136,7 +116,7 @@ ProcXGrabDeviceButton(ClientPtr client)
X_GrabDeviceButton)) != Success)
return ret;
param = (GrabParameters) {
GrabParameters param = {
.grabtype = XI,
.ownerEvents = stuff->ownerEvents,
.this_device_mode = stuff->this_device_mode,

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GRABDEVB_H
#define GRABDEVB_H 1
int SProcXGrabDeviceButton(ClientPtr /* client */
);
int ProcXGrabDeviceButton(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -65,25 +66,6 @@ SOFTWARE.
#include "grabdev.h"
#include "grabdevk.h"
/***********************************************************************
*
* Handle requests from clients with a different byte order.
*
*/
int _X_COLD
SProcXGrabDeviceKey(ClientPtr client)
{
REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
swaps(&stuff->event_count);
REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
return (ProcXGrabDeviceKey(client));
}
/***********************************************************************
*
* Grab a key on an extension device.
@ -98,15 +80,14 @@ ProcXGrabDeviceKey(ClientPtr client)
DeviceIntPtr mdev;
XEventClass *class;
struct tmask tmp[EMASKSIZE];
GrabParameters param;
GrabMask mask;
REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
if (client->req_len !=
bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count)
return BadLength;
REQUEST_HEAD_AT_LEAST(xGrabDeviceKeyReq);
REQUEST_FIELD_CARD32(grabWindow);
REQUEST_FIELD_CARD16(modifiers);
REQUEST_FIELD_CARD16(event_count);
REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32));
REQUEST_BUF_CARD32(&stuff[1], stuff->event_count);
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (ret != Success)
@ -134,7 +115,7 @@ ProcXGrabDeviceKey(ClientPtr client)
X_GrabDeviceKey)) != Success)
return ret;
param = (GrabParameters) {
GrabParameters param = {
.grabtype = XI,
.ownerEvents = stuff->ownerEvents,
.this_device_mode = stuff->this_device_mode,

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GRABDEVK_H
#define GRABDEVK_H 1
int SProcXGrabDeviceKey(ClientPtr /* client */
);
int ProcXGrabDeviceKey(ClientPtr /* client */
);

View File

@ -56,27 +56,12 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exglobals.h"
#include "gtmotion.h"
/***********************************************************************
*
* Swap the request if server and client have different byte ordering.
*
*/
int _X_COLD
SProcXGetDeviceMotionEvents(ClientPtr client)
{
REQUEST(xGetDeviceMotionEventsReq);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
swapl(&stuff->start);
swapl(&stuff->stop);
return (ProcXGetDeviceMotionEvents(client));
}
/****************************************************************************
*
* Get the motion history for an extension pointer devices.
@ -86,8 +71,9 @@ SProcXGetDeviceMotionEvents(ClientPtr client)
int
ProcXGetDeviceMotionEvents(ClientPtr client)
{
REQUEST(xGetDeviceMotionEventsReq);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
REQUEST_HEAD_STRUCT(xGetDeviceMotionEventsReq);
REQUEST_FIELD_CARD32(start);
REQUEST_FIELD_CARD32(stop);
DeviceIntPtr dev;
int rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
@ -102,11 +88,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
MaybeStopDeviceHint(dev, client);
xGetDeviceMotionEventsReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceMotionEvents,
.sequenceNumber = client->sequence,
.length = 0,
.nEvents = 0,
.axes = v->numAxes,
.mode = Absolute /* XXX we don't do relative at the moment */
};
@ -125,8 +107,10 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
rep.nEvents = GetMotionHistory(dev, (xTimecoord **) &coords, /* XXX */
start.milliseconds, stop.milliseconds,
(ScreenPtr) NULL, FALSE);
if (rep.nEvents < 0)
rep.nEvents = 0;
length = rep.nEvents * size;
rep.length = bytes_to_int32(length);
}
}
@ -137,8 +121,9 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
swapl(&rep.nEvents);
}
WriteToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
WriteToClient(client, length, coords);
REPLY_BUF_CARD32(coords, bytes_to_int32(length));
REPLY_FIELD_CARD32(nEvents);
REPLY_SEND_EXTRA(coords, length);
free(coords);
return Success;
}

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GTMOTION_H
#define GTMOTION_H 1
int SProcXGetDeviceMotionEvents(ClientPtr /* client */
);
int ProcXGetDeviceMotionEvents(ClientPtr /* client */
);

View File

@ -58,6 +58,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"
@ -135,9 +136,9 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
b2->class = ButtonClass;
b2->length = sizeof(xButtonInfo);
b2->num_buttons = b->numButtons;
if (client && client->swapped) {
swaps(&b2->num_buttons);
}
CLIENT_STRUCT_CARD16_1(b2, num_buttons);
*buf += sizeof(xButtonInfo);
}
@ -168,9 +169,8 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf)
else
dev->use = IsXExtensionDevice;
if (client->swapped) {
swapl(&dev->type);
}
CLIENT_STRUCT_CARD32_1(dev, type);
*buf += sizeof(xDeviceInfo);
}
@ -191,9 +191,9 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
k2->min_keycode = k->xkbInfo->desc->min_key_code;
k2->max_keycode = k->xkbInfo->desc->max_key_code;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client && client->swapped) {
swaps(&k2->num_keys);
}
CLIENT_STRUCT_CARD16_1(k2, num_keys);
*buf += sizeof(xKeyInfo);
}
@ -229,9 +229,7 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
v2->num_axes = t_axes;
v2->mode = valuator_get_mode(dev, 0);
v2->motion_buffer_size = v->numMotionEvents;
if (client && client->swapped) {
swapl(&v2->motion_buffer_size);
}
CLIENT_STRUCT_CARD32_1(v2, motion_buffer_size);
*buf += sizeof(xValuatorInfo);
a = v->axes + (VPC * i);
a2 = (xAxisInfoPtr) * buf;
@ -239,11 +237,7 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
a2->min_value = a->min_value;
a2->max_value = a->max_value;
a2->resolution = a->resolution;
if (client && client->swapped) {
swapl(&a2->min_value);
swapl(&a2->max_value);
swapl(&a2->resolution);
}
CLIENT_STRUCT_CARD32_3(a2, min_value, max_value, resolution);
a2++;
a++;
*buf += sizeof(xAxisInfo);
@ -325,14 +319,7 @@ ProcXListInputDevices(ClientPtr client)
xDeviceInfo *dev;
DeviceIntPtr d;
REQUEST_SIZE_MATCH(xListInputDevicesReq);
xListInputDevicesReply rep = {
.repType = X_Reply,
.RepType = X_ListInputDevices,
.sequenceNumber = client->sequence,
.length = 0
};
REQUEST_HEAD_STRUCT(xListInputDevicesReq);
/* allocate space for saving skip value */
skip = calloc(inputInfo.numDevices, sizeof(Bool));
@ -382,16 +369,14 @@ ProcXListInputDevices(ClientPtr client)
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
}
rep.ndevices = numdevs;
rep.length = bytes_to_int32(total_length);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
xListInputDevicesReply rep = {
.RepType = X_ListInputDevices,
.ndevices = numdevs,
};
REPLY_SEND_EXTRA(savbuf, total_length);
WriteToClient(client, sizeof(xListInputDevicesReply), &rep);
WriteToClient(client, total_length, savbuf);
free(savbuf);
free(skip);
return Success;

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"
@ -81,8 +82,7 @@ ProcXOpenDevice(ClientPtr client)
int status = Success;
DeviceIntPtr dev;
REQUEST(xOpenDeviceReq);
REQUEST_SIZE_MATCH(xOpenDeviceReq);
REQUEST_HEAD_STRUCT(xOpenDeviceReq);
status = dixLookupDevice(&dev, stuff->deviceid, client, DixUseAccess);
@ -131,19 +131,10 @@ ProcXOpenDevice(ClientPtr client)
evbase[j++].event_type_base = event_base[OtherClass];
xOpenDeviceReply rep = {
.repType = X_Reply,
.RepType = X_OpenDevice,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(j * sizeof(xInputClassInfo)),
.num_classes = j
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xOpenDeviceReply), &rep);
WriteToClient(client, j * sizeof(xInputClassInfo), evbase);
REPLY_SEND_EXTRA(evbase, j * sizeof(xInputClassInfo));
return Success;
}

View File

@ -39,6 +39,7 @@ from The Open Group.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -67,10 +68,8 @@ ProcXQueryDeviceState(ClientPtr client)
ValuatorClassPtr v;
xValuatorState *tv;
DeviceIntPtr dev;
double *values;
REQUEST(xQueryDeviceStateReq);
REQUEST_SIZE_MATCH(xQueryDeviceStateReq);
REQUEST_HEAD_STRUCT(xQueryDeviceStateReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success && rc != BadAccess)
@ -107,9 +106,8 @@ ProcXQueryDeviceState(ClientPtr client)
tk->length = sizeof(xKeyState);
tk->num_keys = k->xkbInfo->desc->max_key_code -
k->xkbInfo->desc->min_key_code + 1;
if (rc != BadAccess)
for (i = 0; i < 32; i++)
tk->keys[i] = k->down[i];
for (i = 0; i < 32; i++)
tk->keys[i] = k->down[i];
buf += sizeof(xKeyState);
}
@ -132,31 +130,20 @@ ProcXQueryDeviceState(ClientPtr client)
tv->mode |= (dev->proximity &&
!dev->proximity->in_proximity) ? OutOfProximity : 0;
buf += sizeof(xValuatorState);
for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
int *buf2 = (int *)buf;
for (i = 0; i < v->numAxes; i++) {
if (rc != BadAccess)
*((int *) buf) = *values;
values++;
if (client->swapped) {
swapl((int *) buf);
}
buf += sizeof(int);
buf2[i] = v->axisVal[i];
}
REPLY_BUF_CARD32(buf2, v->numAxes);
}
xQueryDeviceStateReply rep = {
.repType = X_Reply,
.RepType = X_QueryDeviceState,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(total_length),
.num_classes = num_classes
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xQueryDeviceStateReply), &rep);
WriteToClient(client, total_length, savbuf);
REPLY_SEND_EXTRA(savbuf, total_length);
free(savbuf);
return Success;
}

View File

@ -58,6 +58,7 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -111,25 +112,6 @@ HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
return Success;
}
/***********************************************************************
*
* Handle requests from clients with a different byte order.
*
*/
int _X_COLD
SProcXSelectExtensionEvent(ClientPtr client)
{
REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
swapl(&stuff->window);
swaps(&stuff->count);
REQUEST_FIXED_SIZE(xSelectExtensionEventReq, stuff->count * sizeof(CARD32));
SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
return (ProcXSelectExtensionEvent(client));
}
/***********************************************************************
*
* This procedure selects input from an extension device.
@ -144,12 +126,11 @@ ProcXSelectExtensionEvent(ClientPtr client)
WindowPtr pWin;
struct tmask tmp[EMASKSIZE];
REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
if (client->req_len !=
bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count)
return BadLength;
REQUEST_HEAD_AT_LEAST(xSelectExtensionEventReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD16(count);
REQUEST_FIXED_SIZE(xSelectExtensionEventReq, stuff->count * sizeof(CARD32));
REQUEST_BUF_CARD32(&stuff[1], stuff->count);
ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (ret != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef SELECTEV_H
#define SELECTEV_H 1
int SProcXSelectExtensionEvent(ClientPtr /* client */
);
int ProcXSelectExtensionEvent(ClientPtr /* client */
);

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* Window */
@ -66,53 +67,6 @@ SOFTWARE.
extern int lastEvent; /* Defined in extension.c */
/***********************************************************************
*
* Handle requests from clients with a different byte order than us.
*
*/
int _X_COLD
SProcXSendExtensionEvent(ClientPtr client)
{
CARD32 *p;
int i;
xEvent eventT = { .u.u.type = 0 };
xEvent *eventP;
EventSwapPtr proc;
REQUEST(xSendExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
swapl(&stuff->destination);
swaps(&stuff->count);
if (client->req_len !=
bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
bytes_to_int32(stuff->num_events * sizeof(xEvent)))
return BadLength;
eventP = (xEvent *) &stuff[1];
for (i = 0; i < stuff->num_events; i++, eventP++) {
if (eventP->u.u.type == GenericEvent) {
client->errorValue = eventP->u.u.type;
return BadValue;
}
proc = EventSwapVector[eventP->u.u.type & 0177];
/* no swapping proc; invalid event type? */
if (proc == NotImplemented) {
client->errorValue = eventP->u.u.type;
return BadValue;
}
(*proc) (eventP, &eventT);
*eventP = eventT;
}
p = (CARD32 *) (((xEvent *) &stuff[1]) + stuff->num_events);
SwapLongs(p, stuff->count);
return (ProcXSendExtensionEvent(client));
}
/***********************************************************************
*
* Send an event to some client, as if it had come from an extension input
@ -129,14 +83,42 @@ ProcXSendExtensionEvent(ClientPtr client)
XEventClass *list;
struct tmask tmp[EMASKSIZE];
REQUEST(xSendExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
REQUEST_HEAD_AT_LEAST(xSendExtensionEventReq);
REQUEST_FIELD_CARD32(destination);
REQUEST_FIELD_CARD16(count);
if (client->req_len !=
bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
(stuff->num_events * bytes_to_int32(sizeof(xEvent))))
bytes_to_int32(stuff->num_events * sizeof(xEvent)))
return BadLength;
if (client->swapped) {
CARD32 *p;
xEvent eventT = { .u.u.type = 0 };
xEvent *eventP;
EventSwapPtr proc;
eventP = (xEvent *) &stuff[1];
for (i = 0; i < stuff->num_events; i++, eventP++) {
if (eventP->u.u.type == GenericEvent) {
client->errorValue = eventP->u.u.type;
return BadValue;
}
proc = EventSwapVector[eventP->u.u.type & 0177];
/* no swapping proc; invalid event type? */
if (proc == NotImplemented) {
client->errorValue = eventP->u.u.type;
return BadValue;
}
(*proc) (eventP, &eventT);
*eventP = eventT;
}
p = (CARD32 *) (((xEvent *) &stuff[1]) + stuff->num_events);
SwapLongs(p, stuff->count);
}
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
if (ret != Success)
return ret;

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef SENDEXEV_H
#define SENDEXEV_H 1
int SProcXSendExtensionEvent(ClientPtr /* client */
);
int ProcXSendExtensionEvent(ClientPtr /* client */
);

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exevents.h"
@ -74,8 +75,7 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
int ret;
DeviceIntPtr dev;
REQUEST(xSetDeviceButtonMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
REQUEST_HEAD_AT_LEAST(xSetDeviceButtonMappingReq);
if (client->req_len !=
bytes_to_int32(sizeof(xSetDeviceButtonMappingReq) + stuff->map_length))
@ -101,10 +101,6 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
.status = (ret == Success ? MappingSuccess : MappingBusy),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
REPLY_SEND();
return Success;
}

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -75,13 +76,10 @@ ProcXSetDeviceValuators(ClientPtr client)
DeviceIntPtr dev;
int rc;
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
REQUEST_HEAD_AT_LEAST(xSetDeviceValuatorsReq);
xSetDeviceValuatorsReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceValuators,
.sequenceNumber = client->sequence,
.status = Success
};
@ -111,9 +109,6 @@ ProcXSetDeviceValuators(ClientPtr client)
if (rep.status != Success && rep.status != AlreadyGrabbed)
return rep.status;
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xSetDeviceValuatorsReply), &rep);
REPLY_SEND();
return Success;
}

View File

@ -59,26 +59,11 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "exglobals.h"
#include "setfocus.h"
/***********************************************************************
*
* This procedure sets the focus for a device.
*
*/
int _X_COLD
SProcXSetDeviceFocus(ClientPtr client)
{
REQUEST(xSetDeviceFocusReq);
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
swapl(&stuff->focus);
swapl(&stuff->time);
return (ProcXSetDeviceFocus(client));
}
/***********************************************************************
*
* This procedure sets the focus for a device.
@ -91,8 +76,9 @@ ProcXSetDeviceFocus(ClientPtr client)
int ret;
DeviceIntPtr dev;
REQUEST(xSetDeviceFocusReq);
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
REQUEST_HEAD_STRUCT(xSetDeviceFocusReq);
REQUEST_FIELD_CARD32(focus);
REQUEST_FIELD_CARD32(time);
ret = dixLookupDevice(&dev, stuff->device, client, DixSetFocusAccess);
if (ret != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef SETFOCUS_H
#define SETFOCUS_H 1
int SProcXSetDeviceFocus(ClientPtr /* client */
);
int ProcXSetDeviceFocus(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "exevents.h"
@ -75,8 +76,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
int ret;
DeviceIntPtr dev;
REQUEST(xSetDeviceModifierMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
REQUEST_HEAD_AT_LEAST(xSetDeviceModifierMappingReq);
if (client->req_len != bytes_to_int32(sizeof(xSetDeviceModifierMappingReq)) +
(stuff->numKeyPerModifier << 1))
@ -101,9 +101,6 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
.success = ret,
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(xSetDeviceModifierMappingReply), &rep);
REPLY_SEND();
return Success;
}

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -75,14 +76,10 @@ ProcXSetDeviceMode(ClientPtr client)
DeviceIntPtr dev;
int rc;
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
REQUEST_HEAD_STRUCT(xSetDeviceModeReq);
xSetDeviceModeReply rep = {
.repType = X_Reply,
.RepType = X_SetDeviceMode,
.sequenceNumber = client->sequence,
.length = 0
};
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
@ -113,11 +110,6 @@ ProcXSetDeviceMode(ClientPtr client)
return rep.status;
}
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client, sizeof(xSetDeviceModeReply), &rep);
REPLY_SEND();
return Success;
}

View File

@ -54,6 +54,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -61,21 +62,6 @@ SOFTWARE.
#include "exglobals.h"
#include "ungrdev.h"
/***********************************************************************
*
* Handle requests from a client with a different byte order.
*
*/
int _X_COLD
SProcXUngrabDevice(ClientPtr client)
{
REQUEST(xUngrabDeviceReq);
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
swapl(&stuff->time);
return (ProcXUngrabDevice(client));
}
/***********************************************************************
*
* Release a grab of an extension device.
@ -90,8 +76,8 @@ ProcXUngrabDevice(ClientPtr client)
TimeStamp time;
int rc;
REQUEST(xUngrabDeviceReq);
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
REQUEST_HEAD_STRUCT(xUngrabDeviceReq);
REQUEST_FIELD_CARD32(time);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef UNGRDEV_H
#define UNGRDEV_H 1
int SProcXUngrabDevice(ClientPtr /* client */
);
int ProcXUngrabDevice(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/dixgrabs_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -67,22 +68,6 @@ SOFTWARE.
ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
Mod3Mask | Mod4Mask | Mod5Mask )
/***********************************************************************
*
* Handle requests from a client with a different byte order.
*
*/
int _X_COLD
SProcXUngrabDeviceButton(ClientPtr client)
{
REQUEST(xUngrabDeviceButtonReq);
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
return (ProcXUngrabDeviceButton(client));
}
/***********************************************************************
*
* Release a grab of a button on an extension device.
@ -98,8 +83,9 @@ ProcXUngrabDeviceButton(ClientPtr client)
GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceButtonReq);
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
REQUEST_HEAD_STRUCT(xUngrabDeviceButtonReq);
REQUEST_FIELD_CARD32(grabWindow);
REQUEST_FIELD_CARD16(modifiers);
rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (rc != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef UNGRDEVB_H
#define UNGRDEVB_H 1
int SProcXUngrabDeviceButton(ClientPtr /* client */
);
int ProcXUngrabDeviceButton(ClientPtr /* client */
);

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/dixgrabs_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -69,22 +70,6 @@ SOFTWARE.
ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
Mod3Mask | Mod4Mask | Mod5Mask )
/***********************************************************************
*
* Handle requests from a client with a different byte order.
*
*/
int _X_COLD
SProcXUngrabDeviceKey(ClientPtr client)
{
REQUEST(xUngrabDeviceKeyReq);
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
swapl(&stuff->grabWindow);
swaps(&stuff->modifiers);
return (ProcXUngrabDeviceKey(client));
}
/***********************************************************************
*
* Release a grab of a key on an extension device.
@ -100,8 +85,9 @@ ProcXUngrabDeviceKey(ClientPtr client)
GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceKeyReq);
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
REQUEST_HEAD_STRUCT(xUngrabDeviceKeyReq);
REQUEST_FIELD_CARD32(grabWindow);
REQUEST_FIELD_CARD16(modifiers);
rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (rc != Success)

View File

@ -30,9 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef UNGRDEVK_H
#define UNGRDEVK_H 1
int SProcXUngrabDeviceKey(ClientPtr /* client */
);
int ProcXUngrabDeviceKey(ClientPtr /* client */
);

View File

@ -37,6 +37,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "os/fmt.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -46,42 +47,82 @@
#include "exglobals.h" /* BadDevice */
#include "xiallowev.h"
int _X_COLD
SProcXIAllowEvents(ClientPtr client)
static int allowEvents(ClientPtr client, xXIAllowEventsReq *stuff)
{
REQUEST(xXIAllowEventsReq);
REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq);
DeviceIntPtr dev;
swaps(&stuff->deviceid);
swapl(&stuff->time);
if (client->req_len > 3) {
xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq *) stuff;
int ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)
return ret;
REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
swapl(&req_xi22->touchid);
swapl(&req_xi22->grab_window);
TimeStamp time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode) {
case XIReplayDevice:
AllowSome(client, time, dev, NOT_GRABBED);
break;
case XISyncDevice:
AllowSome(client, time, dev, FREEZE_NEXT_EVENT);
break;
case XIAsyncDevice:
AllowSome(client, time, dev, THAWED);
break;
case XIAsyncPairedDevice:
if (IsMaster(dev))
AllowSome(client, time, dev, THAW_OTHERS);
break;
case XISyncPair:
if (IsMaster(dev))
AllowSome(client, time, dev, FREEZE_BOTH_NEXT_EVENT);
break;
case XIAsyncPair:
if (IsMaster(dev))
AllowSome(client, time, dev, THAWED_BOTH);
break;
default:
client->errorValue = stuff->mode;
ret = BadValue;
}
return ProcXIAllowEvents(client);
return ret;
}
int
ProcXIAllowEvents(ClientPtr client)
{
TimeStamp time;
DeviceIntPtr dev;
int ret = Success;
XIClientPtr xi_client;
Bool have_xi22 = FALSE;
REQUEST(xXI2_2AllowEventsReq);
xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
XIClientPtr xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
if (version_compare(xi_client->major_version,
xi_client->minor_version, 2, 2) >= 0) {
REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
have_xi22 = TRUE;
REQUEST_HEAD_AT_LEAST(xXI2_2AllowEventsReq);
REQUEST_FIELD_CARD16(length);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(time);
REQUEST_FIELD_CARD32(touchid);
REQUEST_FIELD_CARD32(grab_window);
if ((stuff->mode == XIRejectTouch) || (stuff->mode == XIAcceptTouch)) {
DeviceIntPtr dev;
int rc;
WindowPtr win;
int ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)
return ret;
rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess);
if (rc != Success)
return rc;
return TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
stuff->grab_window, &client->errorValue);
}
return allowEvents(client, (xXIAllowEventsReq*)stuff);
} else {
REQUEST_HEAD_AT_LEAST(xXIAllowEventsReq);
REQUEST_FIELD_CARD16(length);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(time);
return allowEvents(client, stuff);
}
else {
REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq);

View File

@ -31,6 +31,5 @@
#define XIALLOWEV_H 1
int ProcXIAllowEvents(ClientPtr client);
int SProcXIAllowEvents(ClientPtr client);
#endif /* XIALLOWEV_H */

View File

@ -46,6 +46,7 @@
#include "dix/cursor_priv.h"
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "os/bug_priv.h"
@ -849,52 +850,33 @@ XIDestroyPointerBarrier(ClientPtr client,
return Success;
}
int _X_COLD
SProcXIBarrierReleasePointer(ClientPtr client)
{
xXIBarrierReleasePointerInfo *info;
REQUEST(xXIBarrierReleasePointerReq);
int i;
REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
swapl(&stuff->num_barriers);
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
return BadLength;
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {
swaps(&info->deviceid);
swapl(&info->barrier);
swapl(&info->eventid);
}
return (ProcXIBarrierReleasePointer(client));
}
int
ProcXIBarrierReleasePointer(ClientPtr client)
{
REQUEST_HEAD_AT_LEAST(xXIBarrierReleasePointerReq);
REQUEST_FIELD_CARD32(num_barriers);
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
return BadLength;
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
int i;
int err;
struct PointerBarrierClient *barrier;
struct PointerBarrier *b;
xXIBarrierReleasePointerInfo *info;
REQUEST(xXIBarrierReleasePointerReq);
REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
return BadLength;
REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
xXIBarrierReleasePointerInfo *info = (xXIBarrierReleasePointerInfo*) &stuff[1];
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {
struct PointerBarrierDevice *pbd;
DeviceIntPtr dev;
CARD32 barrier_id, event_id;
_X_UNUSED CARD32 device_id;
CLIENT_STRUCT_CARD16_1(info, deviceid);
CLIENT_STRUCT_CARD32_2(info, barrier, eventid);
barrier_id = info->barrier;
event_id = info->eventid;

View File

@ -39,7 +39,6 @@ XIDestroyPointerBarrier(ClientPtr client,
Bool XIBarrierInit(void);
void XIBarrierReset(void);
int SProcXIBarrierReleasePointer(ClientPtr client);
int ProcXIBarrierReleasePointer(ClientPtr client);
void XIBarrierNewMasterDevice(ClientPtr client, int deviceid);

View File

@ -38,6 +38,7 @@
#include "dix/cursor_priv.h"
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -54,17 +55,6 @@
*
*/
int _X_COLD
SProcXIChangeCursor(ClientPtr client)
{
REQUEST(xXIChangeCursorReq);
REQUEST_SIZE_MATCH(xXIChangeCursorReq);
swapl(&stuff->win);
swapl(&stuff->cursor);
swaps(&stuff->deviceid);
return (ProcXIChangeCursor(client));
}
int
ProcXIChangeCursor(ClientPtr client)
{
@ -73,8 +63,10 @@ ProcXIChangeCursor(ClientPtr client)
DeviceIntPtr pDev = NULL;
CursorPtr pCursor = NULL;
REQUEST(xXIChangeCursorReq);
REQUEST_SIZE_MATCH(xXIChangeCursorReq);
REQUEST_HEAD_STRUCT(xXIChangeCursorReq);
REQUEST_FIELD_CARD32(win);
REQUEST_FIELD_CARD32(cursor);
REQUEST_FIELD_CARD16(deviceid);
rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)

View File

@ -30,7 +30,6 @@
#ifndef CHDEVCUR_H
#define CHDEVCUR_H 1
int SProcXIChangeCursor(ClientPtr /* client */ );
int ProcXIChangeCursor(ClientPtr /* client */ );
#endif /* CHDEVCUR_H */

View File

@ -42,6 +42,7 @@
#include "dix/exevents_priv.h"
#include "dix/extension_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "os/bug_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -122,13 +123,6 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
free(ev);
}
/***********************************************************************
*
* This procedure allows a client to change the device hierarchy through
* adding new master devices, removing them, etc.
*
*/
static int
add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES])
{
@ -423,7 +417,12 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES])
return rc;
}
#define SWAPIF(cmd) if (client->swapped) { cmd; }
/***********************************************************************
*
* This procedure allows a client to change the device hierarchy through
* adding new master devices, removing them, etc.
*
*/
int
ProcXIChangeHierarchy(ClientPtr client)
@ -438,8 +437,7 @@ ProcXIChangeHierarchy(ClientPtr client)
CHANGED,
} changes = NO_CHANGE;
REQUEST(xXIChangeHierarchyReq);
REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq);
REQUEST_HEAD_AT_LEAST(xXIChangeHierarchyReq);
if (!stuff->num_changes)
return rc;
@ -453,8 +451,7 @@ ProcXIChangeHierarchy(ClientPtr client)
goto unwind;
}
SWAPIF(swaps(&any->type));
SWAPIF(swaps(&any->length));
CLIENT_STRUCT_CARD16_2(any, type, length);
if (len < ((size_t)any->length << 2))
return BadLength;
@ -477,7 +474,7 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = BadLength;
goto unwind;
}
SWAPIF(swaps(&c->name_len));
CLIENT_STRUCT_CARD16_1(c, name_len);
if (c->name_len > (len - sizeof(xXIAddMasterInfo))) {
rc = BadLength;
goto unwind;

View File

@ -31,6 +31,7 @@
#include <X11/extensions/XI2proto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -41,53 +42,27 @@
#include "exglobals.h"
#include "xigetclientpointer.h"
/***********************************************************************
* This procedure allows a client to query another client's client pointer
* setting.
*/
int _X_COLD
SProcXIGetClientPointer(ClientPtr client)
{
REQUEST(xXIGetClientPointerReq);
REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
swapl(&stuff->win);
return ProcXIGetClientPointer(client);
}
int
ProcXIGetClientPointer(ClientPtr client)
{
int rc;
REQUEST_HEAD_STRUCT(xXIGetClientPointerReq);
REQUEST_FIELD_CARD32(win);
ClientPtr winclient;
REQUEST(xXIGetClientPointerReq);
REQUEST_SIZE_MATCH(xXIGetClientPointerReq);
if (stuff->win != None) {
rc = dixLookupResourceOwner(&winclient, stuff->win, client, DixGetAttrAccess);
if (rc != Success)
if (dixLookupResourceOwner(&winclient, stuff->win, client, DixGetAttrAccess) != Success)
return BadWindow;
}
else
winclient = client;
xXIGetClientPointerReply rep = {
.repType = X_Reply,
.RepType = X_XIGetClientPointer,
.sequenceNumber = client->sequence,
.length = 0,
.set = (winclient->clientPtr != NULL),
.deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.deviceid);
}
WriteToClient(client, sizeof(xXIGetClientPointerReply), &rep);
REPLY_FIELD_CARD16(deviceid);
REPLY_SEND();
return Success;
}

View File

@ -30,7 +30,6 @@
#ifndef GETCPTR_H
#define GETCPTR_H 1
int SProcXIGetClientPointer(ClientPtr /* client */ );
int ProcXIGetClientPointer(ClientPtr /* client */ );
#endif /* GETCPTR_H */

View File

@ -36,6 +36,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
@ -44,25 +45,6 @@
#include "xigrabdev.h"
#include "inpututils.h"
int _X_COLD
SProcXIGrabDevice(ClientPtr client)
{
REQUEST(xXIGrabDeviceReq);
/*
* Check here for at least the length of the struct we swap, then
* let ProcXIGrabDevice check the full size after we swap mask_len.
*/
REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
swaps(&stuff->deviceid);
swapl(&stuff->grab_window);
swapl(&stuff->cursor);
swapl(&stuff->time);
swaps(&stuff->mask_len);
return ProcXIGrabDevice(client);
}
int
ProcXIGrabDevice(ClientPtr client)
{
@ -74,7 +56,12 @@ ProcXIGrabDevice(ClientPtr client)
unsigned int keyboard_mode;
unsigned int pointer_mode;
REQUEST(xXIGrabDeviceReq);
REQUEST_HEAD_AT_LEAST(xXIGrabDeviceReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(grab_window);
REQUEST_FIELD_CARD32(cursor);
REQUEST_FIELD_CARD32(time);
REQUEST_FIELD_CARD16(mask_len);
REQUEST_FIXED_SIZE(xXIGrabDeviceReq, ((size_t) stuff->mask_len) * 4);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
@ -123,29 +110,12 @@ ProcXIGrabDevice(ClientPtr client)
return ret;
xXIGrabDeviceReply rep = {
.repType = X_Reply,
.RepType = X_XIGrabDevice,
.sequenceNumber = client->sequence,
.status = status
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(rep), &rep);
return ret;
}
int _X_COLD
SProcXIUngrabDevice(ClientPtr client)
{
REQUEST(xXIUngrabDeviceReq);
REQUEST_SIZE_MATCH(xXIUngrabDeviceReq);
swaps(&stuff->deviceid);
swapl(&stuff->time);
return ProcXIUngrabDevice(client);
REPLY_SEND();
return Success;
}
int
@ -156,8 +126,9 @@ ProcXIUngrabDevice(ClientPtr client)
int ret = Success;
TimeStamp time;
REQUEST(xXIUngrabDeviceReq);
REQUEST_SIZE_MATCH(xXIUngrabDeviceReq);
REQUEST_HEAD_STRUCT(xXIUngrabDeviceReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(time);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)

View File

@ -31,9 +31,7 @@
#define XIGRABDEV_H 1
int ProcXIGrabDevice(ClientPtr client);
int SProcXIGrabDevice(ClientPtr client);
int ProcXIUngrabDevice(ClientPtr client);
int SProcXIUngrabDevice(ClientPtr client);
#endif /* XIGRABDEV_H */

View File

@ -37,6 +37,7 @@
#include "dix/dix_priv.h"
#include "dix/dixgrabs_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
@ -46,45 +47,10 @@
#include "misc.h"
#include "inpututils.h"
int _X_COLD
SProcXIPassiveGrabDevice(ClientPtr client)
{
int i;
uint32_t *mods;
REQUEST(xXIPassiveGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq);
swaps(&stuff->deviceid);
swapl(&stuff->grab_window);
swapl(&stuff->cursor);
swapl(&stuff->time);
swapl(&stuff->detail);
swaps(&stuff->mask_len);
swaps(&stuff->num_modifiers);
REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
((uint32_t) stuff->mask_len + stuff->num_modifiers) *4);
mods = (uint32_t *) &stuff[1] + stuff->mask_len;
for (i = 0; i < stuff->num_modifiers; i++, mods++) {
swapl(mods);
}
return ProcXIPassiveGrabDevice(client);
}
int
ProcXIPassiveGrabDevice(ClientPtr client)
{
DeviceIntPtr dev, mod_dev;
xXIPassiveGrabDeviceReply rep = {
.repType = X_Reply,
.RepType = X_XIPassiveGrabDevice,
.sequenceNumber = client->sequence,
.length = 0,
.num_modifiers = 0
};
int i, ret = Success;
uint32_t *modifiers;
xXIGrabModifierInfo *modifiers_failed = NULL;
@ -93,9 +59,23 @@ ProcXIPassiveGrabDevice(ClientPtr client)
void *tmp;
int mask_len;
REQUEST(xXIPassiveGrabDeviceReq);
REQUEST_HEAD_AT_LEAST(xXIPassiveGrabDeviceReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(grab_window);
REQUEST_FIELD_CARD32(cursor);
REQUEST_FIELD_CARD32(time);
REQUEST_FIELD_CARD32(detail);
REQUEST_FIELD_CARD16(mask_len);
REQUEST_FIELD_CARD16(num_modifiers);
REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
((uint32_t) stuff->mask_len + stuff->num_modifiers) * 4);
((uint32_t) stuff->mask_len + stuff->num_modifiers) *4);
if (client->swapped) {
uint32_t *mods = (uint32_t *) &stuff[1] + stuff->mask_len;
for (i = 0; i < stuff->num_modifiers; i++, mods++) {
swapl(mods);
}
}
if (stuff->deviceid == XIAllDevices)
dev = inputInfo.all_devices;
@ -198,6 +178,8 @@ ProcXIPassiveGrabDevice(ClientPtr client)
mod_dev = (InputDevIsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);
int num_mod = 0;
for (i = 0; i < stuff->num_modifiers; i++, modifiers++) {
uint8_t status = Success;
@ -234,27 +216,24 @@ ProcXIPassiveGrabDevice(ClientPtr client)
}
if (status != GrabSuccess) {
xXIGrabModifierInfo *info = modifiers_failed + rep.num_modifiers;
xXIGrabModifierInfo *info = modifiers_failed + num_mod;
info->status = status;
info->modifiers = *modifiers;
if (client->swapped)
swapl(&info->modifiers);
rep.num_modifiers++;
rep.length += bytes_to_int32(sizeof(xXIGrabModifierInfo));
CLIENT_STRUCT_CARD32_1(info, modifiers);
num_mod++;
}
}
uint32_t length = rep.length; /* save it before swapping */
xXIPassiveGrabDeviceReply rep = {
.RepType = X_XIPassiveGrabDevice,
.num_modifiers = num_mod,
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_modifiers);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, length * 4, modifiers_failed);
uint32_t length = bytes_to_int32(sizeof(xXIGrabModifierInfo) * num_mod);
REPLY_FIELD_CARD16(num_modifiers);
REPLY_SEND_EXTRA(modifiers_failed, length * 4);
out:
free(modifiers_failed);
@ -262,30 +241,6 @@ ProcXIPassiveGrabDevice(ClientPtr client)
return ret;
}
int _X_COLD
SProcXIPassiveUngrabDevice(ClientPtr client)
{
int i;
uint32_t *modifiers;
REQUEST(xXIPassiveUngrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq);
swapl(&stuff->grab_window);
swaps(&stuff->deviceid);
swapl(&stuff->detail);
swaps(&stuff->num_modifiers);
REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq,
((uint32_t) stuff->num_modifiers) << 2);
modifiers = (uint32_t *) &stuff[1];
for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
swapl(modifiers);
return ProcXIPassiveUngrabDevice(client);
}
int
ProcXIPassiveUngrabDevice(ClientPtr client)
{
@ -295,10 +250,20 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
uint32_t *modifiers;
int i, rc;
REQUEST(xXIPassiveUngrabDeviceReq);
REQUEST_HEAD_AT_LEAST(xXIPassiveUngrabDeviceReq);
REQUEST_FIELD_CARD32(grab_window);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(detail);
REQUEST_FIELD_CARD16(num_modifiers);
REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq,
((uint32_t) stuff->num_modifiers) << 2);
if (client->swapped) {
modifiers = (uint32_t *) &stuff[1];
for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
swapl(modifiers);
}
if (stuff->deviceid == XIAllDevices)
dev = inputInfo.all_devices;
else if (stuff->deviceid == XIAllMasterDevices)

View File

@ -30,9 +30,7 @@
#ifndef XIPASSIVEGRAB_H
#define XIPASSIVEGRAB_H 1
int SProcXIPassiveUngrabDevice(ClientPtr client);
int ProcXIPassiveUngrabDevice(ClientPtr client);
int ProcXIPassiveGrabDevice(ClientPtr client);
int SProcXIPassiveGrabDevice(ClientPtr client);
#endif /* XIPASSIVEGRAB_H */

View File

@ -35,6 +35,7 @@
#include "dix/exevents_priv.h"
#include "dix/extension_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "dix.h"
#include "inputstr.h"
@ -852,12 +853,10 @@ ProcXListDeviceProperties(ClientPtr client)
Atom *atoms;
int natoms;
DeviceIntPtr dev;
int rc = Success;
REQUEST(xListDevicePropertiesReq);
REQUEST_SIZE_MATCH(xListDevicePropertiesReq);
REQUEST_HEAD_STRUCT(xListDevicePropertiesReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
int rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
if (rc != Success)
return rc;
@ -866,37 +865,32 @@ ProcXListDeviceProperties(ClientPtr client)
return rc;
xListDevicePropertiesReply rep = {
.repType = X_Reply,
.RepType = X_ListDeviceProperties,
.sequenceNumber = client->sequence,
.length = natoms,
.nAtoms = natoms
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nAtoms);
}
WriteToClient(client, sizeof(xListDevicePropertiesReply), &rep);
if (natoms) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
free(atoms);
}
return rc;
REPLY_FIELD_CARD16(nAtoms);
REPLY_SEND();
free(atoms);
return Success;
}
int
ProcXChangeDeviceProperty(ClientPtr client)
{
REQUEST(xChangeDevicePropertyReq);
REQUEST_HEAD_AT_LEAST(xChangeDevicePropertyReq);
REQUEST_FIELD_CARD32(property);
REQUEST_FIELD_CARD32(type);
REQUEST_FIELD_CARD32(nUnits);
DeviceIntPtr dev;
unsigned long len;
uint64_t totalSize;
int rc;
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
@ -923,11 +917,12 @@ ProcXChangeDeviceProperty(ClientPtr client)
int
ProcXDeleteDeviceProperty(ClientPtr client)
{
REQUEST(xDeleteDevicePropertyReq);
REQUEST_HEAD_STRUCT(xDeleteDevicePropertyReq);
REQUEST_FIELD_CARD32(property);
DeviceIntPtr dev;
int rc;
REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
if (rc != Success)
@ -945,14 +940,18 @@ ProcXDeleteDeviceProperty(ClientPtr client)
int
ProcXGetDeviceProperty(ClientPtr client)
{
REQUEST(xGetDevicePropertyReq);
REQUEST_HEAD_STRUCT(xGetDevicePropertyReq);
REQUEST_FIELD_CARD32(property);
REQUEST_FIELD_CARD32(type);
REQUEST_FIELD_CARD32(longOffset);
REQUEST_FIELD_CARD32(longLength);
DeviceIntPtr dev;
int length;
int rc, format, nitems, bytes_after;
char *data;
Atom type;
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
if (stuff->delete)
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client,
@ -968,9 +967,7 @@ ProcXGetDeviceProperty(ClientPtr client)
return rc;
xGetDevicePropertyReply rep = {
.repType = X_Reply,
.RepType = X_GetDeviceProperty,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(length),
.propertyType = type,
.bytesAfter = bytes_after,
@ -982,14 +979,10 @@ ProcXGetDeviceProperty(ClientPtr client)
if (stuff->delete && (rep.bytesAfter == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.propertyType);
swapl(&rep.bytesAfter);
swapl(&rep.nItems);
}
WriteToClient(client, sizeof(xGenericReply), &rep);
REPLY_FIELD_CARD32(propertyType);
REPLY_FIELD_CARD32(bytesAfter);
REPLY_FIELD_CARD32(nItems);
REPLY_SEND();
if (length) {
switch (rep.format) {
@ -1022,53 +1015,18 @@ ProcXGetDeviceProperty(ClientPtr client)
return Success;
}
int _X_COLD
SProcXChangeDeviceProperty(ClientPtr client)
{
REQUEST(xChangeDevicePropertyReq);
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
swapl(&stuff->property);
swapl(&stuff->type);
swapl(&stuff->nUnits);
return (ProcXChangeDeviceProperty(client));
}
int _X_COLD
SProcXDeleteDeviceProperty(ClientPtr client)
{
REQUEST(xDeleteDevicePropertyReq);
REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
swapl(&stuff->property);
return (ProcXDeleteDeviceProperty(client));
}
int _X_COLD
SProcXGetDeviceProperty(ClientPtr client)
{
REQUEST(xGetDevicePropertyReq);
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
swapl(&stuff->property);
swapl(&stuff->type);
swapl(&stuff->longOffset);
swapl(&stuff->longLength);
return (ProcXGetDeviceProperty(client));
}
/* XI2 Request/reply handling */
int
ProcXIListProperties(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXIListPropertiesReq);
REQUEST_FIELD_CARD16(deviceid);
Atom *atoms;
int natoms;
DeviceIntPtr dev;
int rc = Success;
REQUEST(xXIListPropertiesReq);
REQUEST_SIZE_MATCH(xXIListPropertiesReq);
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
if (rc != Success)
return rc;
@ -1078,19 +1036,14 @@ ProcXIListProperties(ClientPtr client)
return rc;
xXIListPropertiesReply rep = {
.repType = X_Reply,
.RepType = X_XIListProperties,
.sequenceNumber = client->sequence,
.length = natoms,
.num_properties = natoms
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_properties);
}
WriteToClient(client, sizeof(xXIListPropertiesReply), &rep);
REPLY_FIELD_CARD16(num_properties);
REPLY_SEND();
if (natoms) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
@ -1102,13 +1055,17 @@ ProcXIListProperties(ClientPtr client)
int
ProcXIChangeProperty(ClientPtr client)
{
REQUEST_HEAD_AT_LEAST(xXIChangePropertyReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(property);
REQUEST_FIELD_CARD32(type);
REQUEST_FIELD_CARD32(num_items);
int rc;
DeviceIntPtr dev;
uint64_t totalSize;
unsigned long len;
REQUEST(xXIChangePropertyReq);
REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq);
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
@ -1135,12 +1092,13 @@ ProcXIChangeProperty(ClientPtr client)
int
ProcXIDeleteProperty(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXIDeletePropertyReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(property);
DeviceIntPtr dev;
int rc;
REQUEST(xXIDeletePropertyReq);
REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
if (rc != Success)
@ -1158,14 +1116,20 @@ ProcXIDeleteProperty(ClientPtr client)
int
ProcXIGetProperty(ClientPtr client)
{
REQUEST(xXIGetPropertyReq);
REQUEST_HEAD_STRUCT(xXIGetPropertyReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(property);
REQUEST_FIELD_CARD32(type);
REQUEST_FIELD_CARD32(offset);
REQUEST_FIELD_CARD32(len);
DeviceIntPtr dev;
int length;
int rc, format, nitems, bytes_after;
char *data;
Atom type;
REQUEST_SIZE_MATCH(xXIGetPropertyReq);
if (stuff->delete)
UpdateCurrentTime();
rc = dixLookupDevice(&dev, stuff->deviceid, client,
@ -1181,9 +1145,7 @@ ProcXIGetProperty(ClientPtr client)
return rc;
xXIGetPropertyReply rep = {
.repType = X_Reply,
.RepType = X_XIGetProperty,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(length),
.type = type,
.bytes_after = bytes_after,
@ -1194,14 +1156,10 @@ ProcXIGetProperty(ClientPtr client)
if (length && stuff->delete && (rep.bytes_after == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.type);
swapl(&rep.bytes_after);
swapl(&rep.num_items);
}
WriteToClient(client, sizeof(xXIGetPropertyReply), &rep);
REPLY_FIELD_CARD32(type);
REPLY_FIELD_CARD32(bytes_after);
REPLY_FIELD_CARD32(num_items);
REPLY_SEND();
if (length) {
switch (rep.format) {
@ -1234,51 +1192,3 @@ ProcXIGetProperty(ClientPtr client)
return Success;
}
int _X_COLD
SProcXIListProperties(ClientPtr client)
{
REQUEST(xXIListPropertiesReq);
REQUEST_SIZE_MATCH(xXIListPropertiesReq);
swaps(&stuff->deviceid);
return (ProcXIListProperties(client));
}
int _X_COLD
SProcXIChangeProperty(ClientPtr client)
{
REQUEST(xXIChangePropertyReq);
REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq);
swaps(&stuff->deviceid);
swapl(&stuff->property);
swapl(&stuff->type);
swapl(&stuff->num_items);
return (ProcXIChangeProperty(client));
}
int _X_COLD
SProcXIDeleteProperty(ClientPtr client)
{
REQUEST(xXIDeletePropertyReq);
REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
swaps(&stuff->deviceid);
swapl(&stuff->property);
return (ProcXIDeleteProperty(client));
}
int _X_COLD
SProcXIGetProperty(ClientPtr client)
{
REQUEST(xXIGetPropertyReq);
REQUEST_SIZE_MATCH(xXIGetPropertyReq);
swaps(&stuff->deviceid);
swapl(&stuff->property);
swapl(&stuff->type);
swapl(&stuff->offset);
swapl(&stuff->len);
return (ProcXIGetProperty(client));
}

View File

@ -35,22 +35,12 @@ int ProcXChangeDeviceProperty(ClientPtr client);
int ProcXDeleteDeviceProperty(ClientPtr client);
int ProcXGetDeviceProperty(ClientPtr client);
/* request swapping */
int SProcXChangeDeviceProperty(ClientPtr client);
int SProcXDeleteDeviceProperty(ClientPtr client);
int SProcXGetDeviceProperty(ClientPtr client);
/* XI2 request/reply handling */
int ProcXIListProperties(ClientPtr client);
int ProcXIChangeProperty(ClientPtr client);
int ProcXIDeleteProperty(ClientPtr client);
int ProcXIGetProperty(ClientPtr client);
int SProcXIListProperties(ClientPtr client);
int SProcXIChangeProperty(ClientPtr client);
int SProcXIDeleteProperty(ClientPtr client);
int SProcXIGetProperty(ClientPtr client);
void XIResetProperties(void);
#endif /* XIPROPERTY_H */

View File

@ -36,6 +36,7 @@
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "os/fmt.h"
#include "inputstr.h"
@ -53,29 +54,19 @@ static int
ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo * info);
static int SizeDeviceInfo(DeviceIntPtr dev);
static void SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo * info);
int _X_COLD
SProcXIQueryDevice(ClientPtr client)
{
REQUEST(xXIQueryDeviceReq);
REQUEST_SIZE_MATCH(xXIQueryDeviceReq);
swaps(&stuff->deviceid);
return ProcXIQueryDevice(client);
}
int
ProcXIQueryDevice(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXIQueryDeviceReq);
REQUEST_FIELD_CARD16(deviceid);
DeviceIntPtr dev = NULL;
int rc = Success;
int i = 0, len = 0;
char *info, *ptr;
Bool *skip = NULL;
REQUEST(xXIQueryDeviceReq);
REQUEST_SIZE_MATCH(xXIQueryDeviceReq);
if (stuff->deviceid != XIAllDevices &&
stuff->deviceid != XIAllMasterDevices) {
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
@ -110,13 +101,11 @@ ProcXIQueryDevice(ClientPtr client)
}
xXIQueryDeviceReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryDevice,
.sequenceNumber = client->sequence,
.length = len / 4,
.num_devices = 0
};
int buf_len = len;
ptr = info;
if (dev) {
len = ListDeviceInfo(client, dev, (xXIDeviceInfo *) info);
@ -148,15 +137,9 @@ ProcXIQueryDevice(ClientPtr client)
}
}
len = rep.length * 4;
REPLY_FIELD_CARD16(num_devices);
REPLY_SEND_EXTRA(ptr, buf_len);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_devices);
}
WriteToClient(client, sizeof(xXIQueryDeviceReply), &rep);
WriteToClient(client, len, ptr);
free(ptr);
free(skip);
return rc;

View File

@ -33,7 +33,6 @@
#include <X11/extensions/XI2proto.h>
int SProcXIQueryDevice(ClientPtr client);
int ProcXIQueryDevice(ClientPtr client);
int SizeDeviceClasses(DeviceIntPtr dev);
int ListDeviceClasses(ClientPtr client, DeviceIntPtr dev,

View File

@ -40,6 +40,7 @@
#include "dix/eventconvert.h"
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/request_priv.h"
#include "os/fmt.h"
#include "Xext/panoramiXsrv.h"
@ -59,20 +60,13 @@
*
*/
int _X_COLD
SProcXIQueryPointer(ClientPtr client)
{
REQUEST(xXIQueryPointerReq);
REQUEST_SIZE_MATCH(xXIQueryPointerReq);
swaps(&stuff->deviceid);
swapl(&stuff->win);
return (ProcXIQueryPointer(client));
}
int
ProcXIQueryPointer(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXIQueryPointerReq);
REQUEST_FIELD_CARD16(deviceid);
REQUEST_FIELD_CARD32(win);
int rc;
DeviceIntPtr pDev, kbd;
WindowPtr pWin, t;
@ -83,9 +77,6 @@ ProcXIQueryPointer(ClientPtr client)
XIClientPtr xi_client;
Bool have_xi22 = FALSE;
REQUEST(xXIQueryPointerReq);
REQUEST_SIZE_MATCH(xXIQueryPointerReq);
/* Check if client is compliant with XInput 2.2 or later. Earlier clients
* do not know about touches, so we must report emulated button presses. 2.2
* and later clients are aware of touches, so we don't include emulated
@ -124,9 +115,7 @@ ProcXIQueryPointer(ClientPtr client)
pSprite = pDev->spriteInfo->sprite;
xXIQueryPointerReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryPointer,
.sequenceNumber = client->sequence,
.length = 6,
.root = (InputDevCurrentRootWindow(pDev))->drawable.id,
.root_x = double_to_fp1616(pSprite->hot.x),
@ -192,19 +181,14 @@ ProcXIQueryPointer(ClientPtr client)
}
#endif /* XINERAMA */
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.root);
swapl(&rep.child);
swapl(&rep.root_x);
swapl(&rep.root_y);
swapl(&rep.win_x);
swapl(&rep.win_y);
swaps(&rep.buttons_len);
}
WriteToClient(client, sizeof(xXIQueryPointerReply), &rep);
WriteToClient(client, buttons_size, buttons);
REPLY_FIELD_CARD32(root);
REPLY_FIELD_CARD32(child);
REPLY_FIELD_CARD32(root_x);
REPLY_FIELD_CARD32(root_y);
REPLY_FIELD_CARD32(win_x);
REPLY_FIELD_CARD32(win_y);
REPLY_FIELD_CARD16(buttons_len);
REPLY_SEND_EXTRA(buttons, buttons_size);
free(buttons);

View File

@ -30,7 +30,6 @@
#ifndef QUERYDP_H
#define QUERYDP_H 1
int SProcXIQueryPointer(ClientPtr /* client */ );
int ProcXIQueryPointer(ClientPtr /* client */ );
#endif /* QUERYDP_H */

View File

@ -36,6 +36,7 @@
#include <X11/extensions/XI2proto.h>
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "os/fmt.h"
#include "inputstr.h"
@ -54,12 +55,13 @@ extern XExtensionVersion XIVersion; /* defined in getvers.c */
int
ProcXIQueryVersion(ClientPtr client)
{
REQUEST_HEAD_AT_LEAST(xXIQueryVersionReq);
REQUEST_FIELD_CARD16(major_version);
REQUEST_FIELD_CARD16(minor_version);
XIClientPtr pXIClient;
int major, minor;
REQUEST(xXIQueryVersionReq);
REQUEST_SIZE_MATCH(xXIQueryVersionReq);
/* This request only exists after XI2 */
if (stuff->major_version < 2) {
client->errorValue = stuff->major_version;
@ -113,31 +115,12 @@ ProcXIQueryVersion(ClientPtr client)
}
xXIQueryVersionReply rep = {
.repType = X_Reply,
.RepType = X_XIQueryVersion,
.sequenceNumber = client->sequence,
.major_version = major,
.minor_version = minor
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.major_version);
swaps(&rep.minor_version);
}
WriteToClient(client, sizeof(xXIQueryVersionReply), &rep);
REPLY_FIELD_CARD16(major_version);
REPLY_FIELD_CARD16(minor_version);
return Success;
}
/* Swapping routines */
int _X_COLD
SProcXIQueryVersion(ClientPtr client)
{
REQUEST(xXIQueryVersionReq);
REQUEST_AT_LEAST_SIZE(xXIQueryVersionReq);
swaps(&stuff->major_version);
swaps(&stuff->minor_version);
return (ProcXIQueryVersion(client));
}

View File

@ -33,7 +33,6 @@
#ifndef QUERYVERSION_H
#define QUERYVERSION_H 1
int SProcXIQueryVersion(ClientPtr client);
int ProcXIQueryVersion(ClientPtr client);
#endif /* QUERYVERSION_H */

View File

@ -29,6 +29,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "dixstruct.h"
@ -113,39 +114,36 @@ XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len)
return Success;
}
int _X_COLD
SProcXISelectEvents(ClientPtr client)
{
int i;
int len;
xXIEventMask *evmask;
REQUEST(xXISelectEventsReq);
REQUEST_AT_LEAST_SIZE(xXISelectEventsReq);
swapl(&stuff->win);
swaps(&stuff->num_masks);
len = client->req_len - bytes_to_int32(sizeof(xXISelectEventsReq));
evmask = (xXIEventMask *) &stuff[1];
for (i = 0; i < stuff->num_masks; i++) {
if (len < bytes_to_int32(sizeof(xXIEventMask)))
return BadLength;
len -= bytes_to_int32(sizeof(xXIEventMask));
swaps(&evmask->deviceid);
swaps(&evmask->mask_len);
if (len < evmask->mask_len)
return BadLength;
len -= evmask->mask_len;
evmask =
(xXIEventMask *) (((char *) &evmask[1]) + evmask->mask_len * 4);
}
return (ProcXISelectEvents(client));
}
int
ProcXISelectEvents(ClientPtr client)
{
REQUEST_HEAD_AT_LEAST(xXISelectEventsReq);
REQUEST_FIELD_CARD32(win);
REQUEST_FIELD_CARD16(num_masks);
if (stuff->num_masks == 0)
return BadValue;
if (client->swapped) {
int i;
int len;
xXIEventMask *evmask;
len = stuff->length - bytes_to_int32(sizeof(xXISelectEventsReq));
evmask = (xXIEventMask *) &stuff[1];
for (i = 0; i < stuff->num_masks; i++) {
if (len < bytes_to_int32(sizeof(xXIEventMask)))
return BadLength;
len -= bytes_to_int32(sizeof(xXIEventMask));
CLIENT_STRUCT_CARD16_2(evmask, deviceid, mask_len);
if (len < evmask->mask_len)
return BadLength;
len -= evmask->mask_len;
evmask =
(xXIEventMask *) (((char *) &evmask[1]) + evmask->mask_len * 4);
}
}
int rc, num_masks;
WindowPtr win;
DeviceIntPtr dev;
@ -154,12 +152,6 @@ ProcXISelectEvents(ClientPtr client)
int *types = NULL;
int len;
REQUEST(xXISelectEventsReq);
REQUEST_AT_LEAST_SIZE(xXISelectEventsReq);
if (stuff->num_masks == 0)
return BadValue;
rc = dixLookupWindow(&win, stuff->win, client, DixReceiveAccess);
if (rc != Success)
return rc;
@ -327,40 +319,25 @@ ProcXISelectEvents(ClientPtr client)
return Success;
}
int _X_COLD
SProcXIGetSelectedEvents(ClientPtr client)
{
REQUEST(xXIGetSelectedEventsReq);
REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq);
swapl(&stuff->win);
return (ProcXIGetSelectedEvents(client));
}
int
ProcXIGetSelectedEvents(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXIGetSelectedEventsReq);
REQUEST_FIELD_CARD32(win);
int rc, i;
WindowPtr win;
char *buffer = NULL;
OtherInputMasks *masks;
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
DeviceIntPtr dev;
REQUEST(xXIGetSelectedEventsReq);
REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq);
rc = dixLookupWindow(&win, stuff->win, client, DixGetAttrAccess);
if (rc != Success)
return rc;
xXIGetSelectedEventsReply rep = {
.repType = X_Reply,
.RepType = X_XIGetSelectedEvents,
.sequenceNumber = client->sequence,
.length = 0,
.num_masks = 0
};
masks = wOtherInputMasks(win);
@ -376,10 +353,8 @@ ProcXIGetSelectedEvents(ClientPtr client)
if (!others)
goto finish;
buffer =
calloc(MAXDEVICES, sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE));
if (!buffer)
return BadAlloc;
char buffer[MAXDEVICES * (sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE))];
memset(buffer, 0, sizeof(buffer));
evmask = (xXIEventMask *) buffer;
for (i = 0; i < MAXDEVICES; i++) {
@ -399,12 +374,9 @@ ProcXIGetSelectedEvents(ClientPtr client)
evmask->deviceid = i;
evmask->mask_len = mask_len;
rep.num_masks++;
rep.length += sizeof(xXIEventMask) / 4 + evmask->mask_len;
length += sizeof(xXIEventMask) + mask_len * 4;
if (client->swapped) {
swaps(&evmask->deviceid);
swaps(&evmask->mask_len);
}
CLIENT_STRUCT_CARD16_2(evmask, deviceid, mask_len);
memcpy(&evmask[1], devmask, j + 1);
evmask = (xXIEventMask *) ((char *) evmask +
@ -417,14 +389,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
finish: ;
uint32_t length = rep.length; /* save before swapping it */
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_masks);
}
WriteToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
WriteToClient(client, length * 4, buffer);
free(buffer);
REPLY_FIELD_CARD16(num_masks);
REPLY_SEND_EXTRA(buffer, length);
return Success;
}

View File

@ -30,9 +30,7 @@
#ifndef XISELECTEVENTS_H
#define XISELECTEVENTS_H 1
int SProcXISelectEvents(ClientPtr client);
int ProcXISelectEvents(ClientPtr client);
int SProcXIGetSelectedEvents(ClientPtr client);
int ProcXIGetSelectedEvents(ClientPtr client);
#endif /* _XISELECTEVENTS_H_ */

View File

@ -34,40 +34,32 @@
#include <X11/X.h> /* for inputstr.h */
#include <X11/Xproto.h> /* Request macro */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2proto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2proto.h>
#include "extnsionst.h"
#include "exevents.h"
#include "exglobals.h"
#include "xisetclientpointer.h"
int _X_COLD
SProcXISetClientPointer(ClientPtr client)
{
REQUEST(xXISetClientPointerReq);
REQUEST_SIZE_MATCH(xXISetClientPointerReq);
swapl(&stuff->win);
swaps(&stuff->deviceid);
return (ProcXISetClientPointer(client));
}
int
ProcXISetClientPointer(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXISetClientPointerReq);
REQUEST_FIELD_CARD32(win);
REQUEST_FIELD_CARD16(deviceid);
DeviceIntPtr pDev;
ClientPtr targetClient;
int rc;
REQUEST(xXISetClientPointerReq);
REQUEST_SIZE_MATCH(xXISetClientPointerReq);
rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixManageAccess);
if (rc != Success) {
client->errorValue = stuff->deviceid;

Some files were not shown because too many files have changed in this diff Show More