dix: add screen hook for post-close

In contrast to the already existing ScreenClose hook, this one is
called *after* the driver's CloseScreen() proc. That's required for
some extensions (eg. damage) where drivers still need to call in
inside of their CloseScreen procs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-07-02 14:24:10 +02:00 committed by Enrico Weigelt
parent 4036b8c163
commit 56650ba873
4 changed files with 39 additions and 0 deletions

View File

@ -23,6 +23,7 @@ void dixFreeScreen(ScreenPtr pScreen)
DeleteCallbackList(&pScreen->hookWindowDestroy); DeleteCallbackList(&pScreen->hookWindowDestroy);
DeleteCallbackList(&pScreen->hookWindowPosition); DeleteCallbackList(&pScreen->hookWindowPosition);
DeleteCallbackList(&pScreen->hookClose); DeleteCallbackList(&pScreen->hookClose);
DeleteCallbackList(&pScreen->hookPostClose);
DeleteCallbackList(&pScreen->hookPixmapDestroy); DeleteCallbackList(&pScreen->hookPixmapDestroy);
free(pScreen); free(pScreen);
} }

View File

@ -28,6 +28,7 @@
DECLARE_HOOK_PROC(WindowDestroy, hookWindowDestroy, XorgScreenWindowDestroyProcPtr); DECLARE_HOOK_PROC(WindowDestroy, hookWindowDestroy, XorgScreenWindowDestroyProcPtr);
DECLARE_HOOK_PROC(WindowPosition, hookWindowPosition, XorgScreenWindowPositionProcPtr); DECLARE_HOOK_PROC(WindowPosition, hookWindowPosition, XorgScreenWindowPositionProcPtr);
DECLARE_HOOK_PROC(Close, hookClose, XorgScreenCloseProcPtr); DECLARE_HOOK_PROC(Close, hookClose, XorgScreenCloseProcPtr);
DECLARE_HOOK_PROC(PostClose, hookPostClose, XorgScreenCloseProcPtr);
DECLARE_HOOK_PROC(PixmapDestroy, hookPixmapDestroy, XorgScreenPixmapDestroyProcPtr); DECLARE_HOOK_PROC(PixmapDestroy, hookPixmapDestroy, XorgScreenPixmapDestroyProcPtr);
DECLARE_HOOK_PROC(PostCreateResources, hookPostCreateResources, DECLARE_HOOK_PROC(PostCreateResources, hookPostCreateResources,
XorgScreenPostCreateResourcesProcPtr); XorgScreenPostCreateResourcesProcPtr);
@ -71,6 +72,8 @@ void dixScreenRaiseClose(ScreenPtr pScreen) {
if (pScreen->CloseScreen) if (pScreen->CloseScreen)
pScreen->CloseScreen(pScreen); pScreen->CloseScreen(pScreen);
CallCallbacks(&pScreen->hookPostClose, NULL);
} }
void dixScreenRaisePixmapDestroy(PixmapPtr pPixmap) void dixScreenRaisePixmapDestroy(PixmapPtr pPixmap)

View File

@ -147,6 +147,37 @@ _X_EXPORT
void dixScreenUnhookClose(ScreenPtr pScreen, void dixScreenUnhookClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func); XorgScreenCloseProcPtr func);
/**
* @brief register a screen post close notify hook on the given screen
*
* @param pScreen pointer to the screen to register the notify hook into
* @param func pointer to the hook function
*
* In contrast to Close hook, it's called *after* the driver's CloseScreen()
* proc had been called.
*
* When registration fails, the server aborts.
**/
void dixScreenHookPostClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func);
/**
* @brief unregister a screen close 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 dixScreenHookPostClose
*
* Unregister a screen close notify hook registered via @ref dixScreenHookPostClose
*
* In contrast to Close hook, it's called *after* the driver's CloseScreen()
* proc had been called.
**/
void dixScreenUnhookPostClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func);
/* prototype of pixmap destroy notification handler */ /* prototype of pixmap destroy notification handler */
typedef void (*XorgScreenPixmapDestroyProcPtr)(CallbackListPtr *pcbl, typedef void (*XorgScreenPixmapDestroyProcPtr)(CallbackListPtr *pcbl,
ScreenPtr pScreen, ScreenPtr pScreen,

View File

@ -696,6 +696,10 @@ typedef struct _Screen {
CallbackListPtr hookPostCreateResources; CallbackListPtr hookPostCreateResources;
SetWindowVRRModeProcPtr SetWindowVRRMode; SetWindowVRRModeProcPtr SetWindowVRRMode;
/* additional screen post-close notify hooks (replaces wrapping CloseScreen)
should NOT be touched outside of DIX core */
CallbackListPtr hookPostClose;
} ScreenRec; } ScreenRec;
static inline RegionPtr static inline RegionPtr