diff --git a/dix/screen.c b/dix/screen.c index 3c3b715a7..fe39a275c 100644 --- a/dix/screen.c +++ b/dix/screen.c @@ -23,6 +23,7 @@ void dixFreeScreen(ScreenPtr pScreen) DeleteCallbackList(&pScreen->hookWindowDestroy); DeleteCallbackList(&pScreen->hookWindowPosition); DeleteCallbackList(&pScreen->hookClose); + DeleteCallbackList(&pScreen->hookPostClose); DeleteCallbackList(&pScreen->hookPixmapDestroy); free(pScreen); } diff --git a/dix/screen_hooks.c b/dix/screen_hooks.c index 1c96fa211..d3c0ab435 100644 --- a/dix/screen_hooks.c +++ b/dix/screen_hooks.c @@ -28,6 +28,7 @@ DECLARE_HOOK_PROC(WindowDestroy, hookWindowDestroy, XorgScreenWindowDestroyProcPtr); DECLARE_HOOK_PROC(WindowPosition, hookWindowPosition, XorgScreenWindowPositionProcPtr); DECLARE_HOOK_PROC(Close, hookClose, XorgScreenCloseProcPtr); +DECLARE_HOOK_PROC(PostClose, hookPostClose, XorgScreenCloseProcPtr); DECLARE_HOOK_PROC(PixmapDestroy, hookPixmapDestroy, XorgScreenPixmapDestroyProcPtr); DECLARE_HOOK_PROC(PostCreateResources, hookPostCreateResources, XorgScreenPostCreateResourcesProcPtr); @@ -71,6 +72,8 @@ void dixScreenRaiseClose(ScreenPtr pScreen) { if (pScreen->CloseScreen) pScreen->CloseScreen(pScreen); + + CallCallbacks(&pScreen->hookPostClose, NULL); } void dixScreenRaisePixmapDestroy(PixmapPtr pPixmap) diff --git a/dix/screen_hooks_priv.h b/dix/screen_hooks_priv.h index 01e4d8d9b..3ab6bfdda 100644 --- a/dix/screen_hooks_priv.h +++ b/dix/screen_hooks_priv.h @@ -147,6 +147,37 @@ _X_EXPORT void dixScreenUnhookClose(ScreenPtr pScreen, 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 */ typedef void (*XorgScreenPixmapDestroyProcPtr)(CallbackListPtr *pcbl, ScreenPtr pScreen, diff --git a/include/scrnintstr.h b/include/scrnintstr.h index d1f99840f..71ef762ea 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -696,6 +696,10 @@ typedef struct _Screen { CallbackListPtr hookPostCreateResources; SetWindowVRRModeProcPtr SetWindowVRRMode; + + /* additional screen post-close notify hooks (replaces wrapping CloseScreen) + should NOT be touched outside of DIX core */ + CallbackListPtr hookPostClose; } ScreenRec; static inline RegionPtr