Commit Graph

1059 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
6bc438ab5a treewide: use inline helper for accessing first screen
Instead of everybody directly accessing the (internal) screenInfo struct,
let those consumers only interested in first screen use a little helper.

Also caching the value if it's needed several times.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:45:05 +02:00
Enrico Weigelt, metux IT consult
006f0ec78c Xi: move VPC define into the only source using it
Only used inside listdev.c, so no need to have it within a header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:42:31 +02:00
Enrico Weigelt, metux IT consult
b5210be9eb Xi: helper for private structure retrieval
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-10 13:41:47 +02:00
Enrico Weigelt, metux IT consult
a324351f67 treewide: drop unnecessary includes of Xi/eglobals.h
Dropping include by sources that don't use anything from this header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-09 14:41:10 +02:00
Enrico Weigelt, metux IT consult
f00f20aa8e Xi: ProcXCloseDevice(): compactify the loop a bit
In preparation of upcoming screen iterator macros, compactify the
loop body a little bit. This function is so cold that it's not
really worth caching the screen's root window pointer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-04 11:08:19 +02:00
Enrico Weigelt, metux IT consult
06af052eb7 Xi: SendEventToAllWindows(): drop unneeded local variable
Only used once as paramter, so we can use its assigned value directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-04 11:07:32 +02:00
Enrico Weigelt, metux IT consult
d47357e6c9 Xi: inline SProcXGetDeviceControl()
move the only one relevant line into ProcXGetDeviceControl()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-03 10:10:48 +02:00
Enrico Weigelt, metux IT consult
f8ad69698a treewide return code of X_SEND_REPLY_WITH_RPCBUF()
The macro will automatically return BadAlloc if the buffer is broken,
otherwise Success. Thus, we don't need extra prior rpcbuf check.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-09-02 12:48:50 +02:00
Enrico Weigelt, metux IT consult
34a27eacce Xi: ProcXIQueryPointer(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 16:10:06 +02:00
Enrico Weigelt, metux IT consult
6efd1a85e8 Xi: ProcXIAllowEvents(): untwist request header handling
The Xi protocol has some pretty unclean design aspect: instead of adding a
new sub-request type, version 2.2 introduced a different request structure
with some extra fields. So depending on which version the client has selected,
we need to operate on separate structs.

In the current implementation, there's a unclean hack by using the extended
structure and only accessing the extra fields when using v2.2 or above.
Even though this works, it's making the code unnecessarily complicated and
blocking the use if canonical request parsing macros (which are coming with
subsequent commits).

Thus, it's time to clean it up and only use the exactly correct structs
in the two different cases. The trick is just branching by version and pick
out the the interesting values from the corresponding structs, so they can
later be used in the (mostly) version independent part.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 16:09:10 +02:00
Enrico Weigelt, metux IT consult
8c90875c3d Xi: ProcXListInputDevices(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 16:04:18 +02:00
Enrico Weigelt, metux IT consult
a27f18d1c6 Xi: ProcXGetDeviceControl() also use x_rpcbuf_t for byte-swapping
Use x_rpcbuf_t also for writing individual fields and so let it also
do the byte-swapping.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 14:16:18 +02:00
Enrico Weigelt, metux IT consult
e223abb80e Xi: ProcXISelectEvents() declare variables where needed
For better readability, declare the variables only where they're used,
and try to scope them, instead of declaring them all on the very top.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-31 10:04:27 +02:00
Enrico Weigelt, metux IT consult
cb0ab6ae0b Xi: ProcXIPassiveGrabDevice(): move rpcbuf declaration upwards
The code below the `out` label is using the rpcbuf variable, but we have
a jump site before the variable is declared. It had been overlooked, because
for yet unknown reasons the compiler doesn't complain at all about this.
We could assume that it at least moves the stack allocation upwards
(always could even happen even on function entry), but we don't know whether
the memory is already unitialized.

So, to be on safe-side, move the declaration upwards, before the first
jump site.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 14:32:39 +02:00
Enrico Weigelt, metux IT consult
0075fca5fb Xi: ProcXIPassiveGrabDevice(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:20:17 +02:00
Enrico Weigelt, metux IT consult
6413bd61d7 Xi: ProcXGetFeedbackControl(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:11:43 +02:00
Enrico Weigelt, metux IT consult
e46ea5c7eb Xi: ProcXGetDeviceMotionEvents(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:11:32 +02:00
Enrico Weigelt, metux IT consult
eee0a6b1fd Xi: ProcXGetDeviceModifierMapping(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:11:20 +02:00
Enrico Weigelt, metux IT consult
8ce6636973 Xi: ProcXGetDeviceControl(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:11:10 +02:00
Enrico Weigelt, metux IT consult
e45decb482 Xi: ProcXGetDeviceButtonMapping(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:10:59 +02:00
Enrico Weigelt, metux IT consult
61eb2e2675 Xi: make ListDeviceClasses() static
Only used within the same source file, so can be made static.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 13:10:48 +02:00
Enrico Weigelt, metux IT consult
18d3fd9ac8 Xi: ProcXOpenDevice(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 11:42:31 +02:00
Enrico Weigelt, metux IT consult
68b7098173 Xi: ProcXQueryDeviceState(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 11:42:22 +02:00
Enrico Weigelt, metux IT consult
a7a48427f5 Xi: ProcXIQueryDevice(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 11:39:59 +02:00
Enrico Weigelt, metux IT consult
5281024261 Xi: ProcXIQueryPointer(): use x_rpcbuf_t
use x_rpcbuf_t for reply payload assembly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-29 11:39:51 +02:00
Enrico Weigelt, metux IT consult
681ff201d5 Xi: replace WriteRpcbufToClient() by X_SEND_REPLY_WITH_RPCBUF() macro
Use the new X_SEND_REPLY_WITH_RPCBUF() macro for final reply write out.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-24 12:11:24 +02:00
Enrico Weigelt, metux IT consult
64996477f5 Xi: xtest: use X_SEND_REPLY_SIMPLE()
Use X_SEND_REPLY_SIMPLE() for sending out simple replies.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-22 14:27:29 +02:00
stefan11111
4c79fd513a Xi: Fix xinput property count
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
2025-08-22 14:27:01 +02:00
Enrico Weigelt, metux IT consult
6730e673d6 Xi: canonical walkScreen variable on screen list iterations
When iterating screen lists, consistently use the same variable name
`walkScreen` for holding current screen pointer everywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-18 10:52:49 +02:00
Enrico Weigelt, metux IT consult
6d6f64da55 Xi: fix size parameter to WriteToClient()
Size computation needs to be done on the struct actually written.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-14 16:52:47 +02:00
Enrico Weigelt, metux IT consult
946eb68ff3 xkb: ProcXGetDeviceKeyMapping(): use x_rpcbuf_t
Using x_rpcbuf_t for payload assembly and byte swapping.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-11 20:26:14 +02:00
Enrico Weigelt, metux IT consult
566f961fd4 dix: fix int-type mismatches related to dixClientIdForXID()
The client index (in the client table) can never be negative, thus
make it an unsigned short.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-11 13:02:14 +02:00
Enrico Weigelt, metux IT consult
95959758dc Xi: drop including <dix-config.h> from internal headers
All their consumers need to include <dix-config.h> at the very top anyways.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-05 12:58:07 +02:00
Enrico Weigelt, metux IT consult
9b32a62d04 Xi: ProcXIGetProperty(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and byte-swap, instead of
writing in little pieces via complicated callbacks.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
232c8d97f8 Xi: simplify ProcXListDeviceProperties() and ProcXIListProperties()
Skip allocation of temporay buffer for the atom IDs, instead walk through
the property list and write the IDs directly into the rpcbuf.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
79ca3103f7 Xi: use x_rpcbuf_t in ProcXListDeviceProperties() and ProcXIListProperties()
x_rpcbuf_t allows easy accumulation of payload data and doing byteswap
(when necessary) at the same time.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
f0341145f0 Xi: ProcXGetDeviceProperty(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and byte-swap, instead of
writing in little pieces via complicated callbacks.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
a857543be6 Xi: ProcXGetSelectedExtensionEvents(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and byte-swapping, instead
of writing in little pieces via complicated callbacks.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
0680117493 Xi: ProcXGetSelectedExtensionEvents(): protect from allocation failure
If allocation fails, bail out with BadAlloc, instead of segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
036cbb4ff2 Xi: ProcXGetDeviceDontPropagateList(): use x_rpcbuf_t
Use x_rpcbuf_t for reply payload assembly and byte-swapping, instead of
writing in little pieces via complicated callbacks.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-08-04 15:58:07 +02:00
Enrico Weigelt, metux IT consult
16246adc8e Xi: use dixAddAtom()
Use the new helper for creating atoms on demand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-23 12:24:27 +02:00
Enrico Weigelt, metux IT consult
42daf8e53e Xi: drop using HAVE_DIX_CONFIG_H
This symbol is always defined, and the header is always present,
so no need to check for it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-23 12:23:06 +02:00
Enrico Weigelt, metux IT consult
cc289d21ce Xi: use NULL instead of NullClient
No need to have another name for NULL, we can use NULL directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-18 22:24:55 +02:00
Enrico Weigelt, metux IT consult
030745a0e7 dix: move inpututils.h and rename it to inpututil_privs.h
it's a private header, thus should not be in public include directory.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-18 04:51:30 +02:00
Enrico Weigelt, metux IT consult
90bfeca905 Xi: drop unused variable and NULL free in ProcXISelectEvents()
The `types` variable is never used, just assigned NULL - and that NULL
value is passed to free(). This code is really doing nothing, never did so
since introduced in 2009.

Fixes: 8b6a370058
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-14 20:26:57 +02:00
Enrico Weigelt, metux IT consult
d3c32cdfa8 Xi: fix wrong assertion in RetrieveTouchDeliveryData()
The assert(iclients) was in a place where the iclients variable could
not have been initialized ever - the first assignment is done *after* that.
Since we already have a BUG_RETURN_VAL() right be before it's actually
dereferenced, there's no need for that assert() at all - so drop it.

See https://github.com/X11Libre/xserver/issues/330

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-09 13:58:31 +02:00
dasha_uwu
7c64a06ba4 treewide: remove "lib" prefix in static_library names (meson)
this was producing static libraries named "liblibsomething.a"

Signed-off-by: dasha_uwu <dasha@linuxping.win>
2025-07-03 12:01:52 +02:00
dec05eba
2f66431927 xi: Fix build on arch linux (cast between struct and union gcc error)
Fixes this build error on arch linux:

../Xi/exevents.c:1394:26: error: array subscript ‘InternalEvent {aka union _InternalEvent}[0]’ is partly outside array bounds of ‘DeviceEvent[1]’ {aka ‘struct _DeviceEvent[1]’} [-Werror=array-bounds=]
 1394 |                 evtype = GetXI2Type(ev->any.type);
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~
../Xi/exevents.c: In function ‘DeliverEmulatedMotionEvent’:
../Xi/exevents.c:1571:17: note: object ‘motion’ of size 432
 1571 |     DeviceEvent motion;
      |

which happens because of change in build options compared to master and gcc 15.1 in arch. I think this warning (and error) is a bug in gcc.

gcc 15.1 doesn't like when struct DeviceEvent is cast to union InternalEvent.
InternalEvent has a union any type and DeviceEvent type and these have to have a matching structure (for the header part).
When the InternalEvent is used in RetrieveTouchDeliveryData function it access the any field, which accessed the data defined previously in the device_event fields.
This change matches how its done in touch.c TouchEmitTouchEnd for example and it's "more correct",
since we are no longer casting from a smaller struct (DeviceEvent) to a larger struct (InternalEvent) when calling RetrieveTouchDeliveryData.

Signed-off-by: dec05eba <dec05eba@protonmail.com>
2025-06-13 19:08:17 +02:00
Enrico Weigelt, metux IT consult
c3f042de23 Xi: allow hooks to silently ignore SelectEvents request
When looking up the window to select on and security hook returns
BadAccess, the request is just silently ignored, instead of rejected.

This way, security hook can prevent untrusted clients to listen on
arbitrary windows, without the client even noticing. The client won't
get this BadAccess error, but instead thinking everything's fine,
just not getting the actual events.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00
Enrico Weigelt, metux IT consult
e6467895f9 dix: add dixAllocServerXID()
Adding a separate function for allocating server-client's XIDs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 17:21:48 +02:00