Commit Graph

2558 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 669391f477 dbe: use window position notify hook
Wrapping ScreenRec's function pointers is problematic for many reasons,
so use the new window position notify hook instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:44:36 +02:00
Enrico Weigelt, metux IT consult 479484b631 dix: add per-screen window position notify hook
Right now, extension specific actions on window positioning are implemented
by wrapping the ScreenRec's PositionWindow() proc pointer: the extensions are
storing the original pointer in their private data and putting in their own one.
On each call, their proc restores the original one, calls it, and switches back
again. When multiple extensions doing so, they're forming a kind of daisy chain.
(the same is done for lots of other procs)

While that approach is looking nice and elegant on the drawing board, it's
complicated, dangerous like a chainsaw and makes debugging hard, leading to
pretty blurred API borders.

This commit introduces a simple approach for letting extension hook into the
window positioning path safely, w/o having to care much about side effects
with the call chain. Extensions now can simply register their hook proc
(and an opaque pointer) and get called back - w/o ever having to mess with
the ScreenRec's internal structures. These hooks are called before the original
vector (usually handled by DDX/screen driver directly) is called.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:44:33 +02:00
Enrico Weigelt, metux IT consult 3a0edc36b6 dix: add per-screen window destructor hook
Right now, extension specific window destruction procedures are implemented
by wrapping the ScreenRec's DestroyWindow() proc pointer: the extensions are
storing the original pointer in their private data and putting in their own one.
On each call, their proc restores the original one, calls it, and switches back
again. When multiple extensions doing so, they're forming a kind of daisy chain.
(the same is done for lots of other procs)

While that approach is looking nice and elegant on the drawing board, it's
complicated, dangerous like a chainsaw and makes debugging hard, leading to
pretty blurred API borders.

This commit introduces a simple approach for letting extension hook into the
window destruction safely, w/o having to care much about side effects with
the call chain. Extensions now can simply register their destructor proc
(and an opaque pointer) and get called back - w/o ever having to mess with
the ScreenRec's internal structures.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:59 +02:00
Enrico Weigelt, metux IT consult 48ca8adc6d dix: make DeleteCallbackList() non-static and document it
Allow using it by other places outside this file, so we can also support
callback lists in dynamically allocated structures:

Those cases need to explicitly call DeleteCallbackList() before free()ing
the structures - otherwise we're getting heap corruptions, because the
actual deletion can happen asynchronously.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:56 +02:00
Enrico Weigelt, metux IT consult a110b3e02e dix: consolidate screen destruction in dixFreeScreen()
Consolidate duplicated screen destruction logic into new function
dixFreeScreen().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:54 +02:00
Enrico Weigelt, metux IT consult 14de20ce58 dix: replace FreeDefaultStipple()
It's just a one-liner only called once, so no actual need for it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:51 +02:00
Enrico Weigelt, metux IT consult d56d8307c1 dix: let FreeGCperDepth() operate on ScreenPtr and NULL protect it
Instead of retrieving the screen index from ScreenRec and passing this,
so the ScreenRec is looked up again, just pass in the ScreenPtr that
already have anyways.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:48 +02:00
Enrico Weigelt, metux IT consult 1eaf1b0191 dix: NULL-protect FreeGC()
Make it possible to call FreeGC() w/o prior NULL checks.
In case of NULL, BadMatch is returned.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:43:23 +02:00
Enrico Weigelt, metux IT consult 2be4669988 dix: a little bit more startup logging
Adding a little bit more logging to the startup process, eg. telling
when outputs or inputs have been initialized. Serving as a little aid for
debugging driver problems.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:50 +02:00
Enrico Weigelt, metux IT consult 8a5b65529c dix: protect input_option_set_value() from NULL pointer
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:47 +02:00
Enrico Weigelt, metux IT consult 3178018b84 dix: extra NULL safety check in SetClipRects()
Even though it might never be actually hit, it's better to have an
(really cheap) extra check, just in case.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:44 +02:00
Enrico Weigelt, metux IT consult 9d13313511 dix: extra NULL protection in UnmapSubwindows()
Even though it probably won't be hit ever, it's still better to be
really sure instead of some remote chance for hard segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:42 +02:00
Enrico Weigelt, metux IT consult ee7e43ab21 dix: clear free()ed pointers on CloseDownExtensions()
As safety precaution, clear the pointers to extion records that just
have been free()ed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:39 +02:00
Enrico Weigelt, metux IT consult 77502c6836 dix: NULL-protect AllocGlyphCursor()
Return error to the client if sourcefont turns out to be NULL for
whatever reason.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:37 +02:00
Enrico Weigelt, metux IT consult af71108cd3 dix: devices: refine NULL checks in GetMaster()
The checking / branchin isn't entirely trivial to understand, and the
analyzer also gets confused. So rewrite it in an simpler way that's
easier to understand both the human reader as well as the analyzer.
(and so get rid of yet another false alarm)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:34 +02:00
Enrico Weigelt, metux IT consult 4d3d4a34ec dix: region: turn xfreeData() into inline func and add checks
For type-safety turn xfreeData() macro into an inline function.
Also adding some checks against accidentially free()'ing global data.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:31 +02:00
Enrico Weigelt, metux IT consult 765cb85350 dix: make DeviceEnterLeaveEvent() anaylzer-friendly
The analyzer giving a false alarm on potential NULL-pointer deref here.
Even though that case can't happen, it's also not immediately clear
to the human reader.

To make both the analyzer as well human reader happier, reformulating
this function to by using fast-return pattern.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:29 +02:00
Enrico Weigelt, metux IT consult 7b7579e956 dix: protect ChangeWindowDeviceCursor() from allocation failure
On memory allocation failure, return BadAlloc instead of crashing.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:26 +02:00
Enrico Weigelt, metux IT consult 2b9ccde53a dix: dixfonts: explain analyzer false alarm on alleged free() of stack chunk
The analyzer is wrong here, because the free'd closure pointer really points
to some calloc()'d chunk, instead of the PolyText()'s stack frame.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:20 +02:00
Enrico Weigelt, metux IT consult 1e47ef4006 dix: NULL-protection in GestureAddRegularListener()
protect against the (unlikely) case that inputMasks == NULL.

| ../dix/gestures.c: In function ‘GestureAddRegularListener’:
| ../include/list.h:376:21: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
|   376 |         for (_entry = _list; _entry; _entry = (_entry)->_member)
| ../dix/gestures.c:241:9: note: in expansion of macro ‘nt_list_for_each_entry’
|   241 |         nt_list_for_each_entry(iclients, inputMasks->inputClients, next) {
|       |         ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:17 +02:00
Enrico Weigelt, metux IT consult f1ba454733 dix: protect from pScreen->SetCursorPosition == NULL
It's safer not relying on all ScreenProc's actually filled.

../dix/events.c: In function ‘CheckPhysLimits’:
../dix/events.c:780:14: warning: dereference of NULL ‘pScreen’ [CWE-476] [-Wanalyzer-null-dereference]
  780 |             (*pScreen->SetCursorPosition)
      |             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:14 +02:00
Enrico Weigelt, metux IT consult 654c9c1f3d dix: touch: NULL-protection in TouchAddRegularListener()
protect against the (unlikely) case that inputMasks == NULL.

| ../dix/touch.c: In function ‘TouchAddRegularListener’:
| ../include/list.h:376:21: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
|   376 |         for (_entry = _list; _entry; _entry = (_entry)->_member)
| ../dix/touch.c:766:9: note: in expansion of macro ‘nt_list_for_each_entry’
|   766 |         nt_list_for_each_entry(iclients, inputMasks->inputClients, next) {
|       |         ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:12 +02:00
Enrico Weigelt, metux IT consult 076bc54064 dix: region: add comments on xfreeData()
Commenting a few aspects need to be considered when using this macro.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:09 +02:00
Enrico Weigelt, metux IT consult e3a213f63c dix: protect against alloc failure in ‘DeviceFocusEvent()
Fixes analyzer warning:

| ../dix/enterleave.c: In function ‘DeviceFocusEvent’:
| ../dix/enterleave.c:788:20: warning: dereference of possibly-NULL ‘xi2event’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   788 |     xi2event->type = GenericEvent;
|   ‘DoFocusEvents’: events 1-4

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:05 +02:00
Enrico Weigelt, metux IT consult 6a8ee31e1b dix: move props into WindowRec and fix potential NULL deref
The pointer to the window properties is currently inside the WindowOptional
structure, which may or may not exist at any given time. Thus, before accessing
those fields, at least need to check whether it exists, potentially need to
create it first.

Since a pointer is small (in relation to WindowRec) and windows having properties
is a pretty common, we can make our life much simpler here by moving the pointer
directly into WindowRec, so we don't need extra WindowOptionalRec allocation.

This also fixes an analyzer warning on potential NULL dereference issue:

| ../dix/property.c: In function ‘dixChangeWindowProperty’:
|../dix/property.c:343:37: warning: dereference of NULL ‘*pWin.optional’ [CWE-476] [-Wanalyzer-null-dereference]
|  343 |         pProp->next = pWin->optional->userProps;
|      |                       ~~~~~~~~~~~~~~^~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:34:03 +02:00
Enrico Weigelt, metux IT consult faae695d0a dix: protect doPolyText() from potential NULL dereference
There's a (theoretical) chance that origGC might be NULL, so better
be cautious and check for this - doesn't cost us much, probably just
another JZ instruction.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:33:57 +02:00
Enrico Weigelt, metux IT consult 233ea698e6 XI: unexport XIPropToInt() and XIPropToFloat()
Not used by any drivers, and subject to upcoming changes, so no need
to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:25:48 +02:00
Enrico Weigelt, metux IT consult 25f50e2cc5 panoramix: replace FOR_NSCREENS() by FOR_NSCREENS_BACKWARD(i)
FOR_NSCREENS() is just alias for FOR_NSCREENS_BACKWARD(). In many cases
it really matters that we're going backwards and the last iteration visited
the screen #0, and that one is panoramix-wrapped.

Thus directly calling FOR_NSCREENS_BACKWARD() here and dropping the alias.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:24:18 +02:00
Enrico Weigelt, metux IT consult 38e8cc47f5 dix: drop unused SetVendorRelease()
Not used anywhere, so no need to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:19 +02:00
Enrico Weigelt, metux IT consult 06dbab958c dix: unexport InitAtoms() and FreeAllAtoms()
Not used by any drivers, very DIX-internal, so should not be part
of public API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:15 +02:00
Enrico Weigelt, metux IT consult 39b0c088d5 dix: replace AtomError() by better messages
Not used by any exteral drivers (and really should not be used by them),
so can be replaced by more fitting error messages.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:12 +02:00
Enrico Weigelt, metux IT consult 9d78e139a0 dix: unexport SetInputCheck() and make it inline
Not used by any drivers, so no need to keep it exported.
It's also so simple (and rarely called) that easily can be inlined.

Also unexport HWEventQueueType and HWEventQueuePtr, since they're
not used by any drivers.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:09 +02:00
Enrico Weigelt, metux IT consult b4d1ad0eaf dix: unexport LastEventTimeToggleResetAll()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:06 +02:00
Enrico Weigelt, metux IT consult 5b848b0dcc dix: unexport LastEventTimeToggleResetFlag()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:04 +02:00
Enrico Weigelt, metux IT consult afaafb5e6c dix: unexport LastEventTimeWasReset()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:20:01 +02:00
Enrico Weigelt, metux IT consult 64d15c4511 dix: unexport LastEventTime()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:58 +02:00
Enrico Weigelt, metux IT consult 34001b0102 dix: unexport NoticeEventTime()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:55 +02:00
Enrico Weigelt, metux IT consult c734df44ff dix: unexport NoticeTime()
Not used by any external drivers, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:52 +02:00
Enrico Weigelt, metux IT consult 2f7ba4bf32 dix: unexport InitBlockAndWakeupHandlers()
Not supposed to be called by drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:49 +02:00
Enrico Weigelt, metux IT consult f069b91c8a dix: unexport WakeupHandler()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:46 +02:00
Enrico Weigelt, metux IT consult 9f0d07a7d9 dix: unexport BlockHandler()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:43 +02:00
Enrico Weigelt, metux IT consult 6dc7eab871 dix: rename IsFloating() to InputDevIsFloating()
Give it a better fitting name.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:40 +02:00
Enrico Weigelt, metux IT consult 985f4c22c6 dix: unexport and document IsFloating()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:36 +02:00
Enrico Weigelt, metux IT consult 4f2bd438cd dix: rename IsMaster to InputDevIsMaster()
Give it a better fitting name.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:33 +02:00
Enrico Weigelt, metux IT consult 1b3de34f22 dix: unexport IsMaster()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:30 +02:00
Enrico Weigelt, metux IT consult 537f8c4b82 dix: unexport IsKeyboardDevice()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:27 +02:00
Enrico Weigelt, metux IT consult 57bc6cb633 dix: unexport IsPointerDevice()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:24 +02:00
Enrico Weigelt, metux IT consult 6fc8b593a4 dix: rename IsParent() to WindowIsParent()
Spending it a more fitting name.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:21 +02:00
Enrico Weigelt, metux IT consult abcd627d40 dix: unexport IsParent()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:18 +02:00
Enrico Weigelt, metux IT consult 14dba35dac dix: unexport PickKeyboard()
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-12 16:19:15 +02:00