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>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-09-24 17:58:33 +02:00
parent 6967c0033c
commit 479484b631
8 changed files with 85 additions and 12 deletions

View File

@@ -71,4 +71,42 @@ void dixScreenHookWindowDestroy(ScreenPtr pScreen,
void dixScreenUnhookWindowDestroy(ScreenPtr pScreen,
XorgScreenWindowDestroyProcPtr func);
typedef struct {
WindowPtr window;
int32_t x;
int32_t y;
} XorgScreenWindowPositionParamRec;
/* prototype of a window move notification handler */
typedef void (*XorgScreenWindowPositionProcPtr)(CallbackListPtr *pcbl,
ScreenPtr pScreen,
XorgScreenWindowPositionParamRec *param);
/**
* @brief register a position notify hook on the given screen
*
* @param pScreen pointer to the screen to register the notify hook into
* @param func pointer to the window hook function
* @param arg opaque pointer passed to the hook
*
* When registration fails, the server aborts.
*
**/
void dixScreenHookWindowPosition(ScreenPtr pScreen,
XorgScreenWindowPositionProcPtr func);
/**
* @brief unregister a window position notify hook on the given screen
*
* @param pScreen pointer to the screen to unregister the hook from
* @param func pointer to the hook function
* @param arg opaque pointer passed to the destructor
*
* @see dixScreenHookWindowPosition
*
* Unregister a window position notify hook registered via @ref dixScreenHookWindowPosition
**/
void dixScreenUnhookWindowPosition(ScreenPtr pScreen,
XorgScreenWindowPositionProcPtr func);
#endif /* DIX_SCREEN_HOOKS_H */