dix: add per-screen close notify hook

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-09-27 19:01:23 +02:00
parent 979dfaf30a
commit b23091f99c
5 changed files with 64 additions and 0 deletions

View File

@ -289,4 +289,16 @@ int dixScreenRaiseWindowDestroy(WindowPtr pWin);
*/ */
void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y); void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y);
/*
* @brief call screen's close hooks
* @see dixScreenHookClose
* @param pScreen the screen being closed
*
* Call the pluggable screen close hooks that extensions might have registered on
* the screen, and finally call ScreenRec's CloseScreen proc.
*
* Should only be called by DIX itself.
*/
void dixScreenRaiseClose(ScreenPtr pScreen);
#endif /* _XSERVER_DIX_PRIV_H */ #endif /* _XSERVER_DIX_PRIV_H */

View File

@ -42,6 +42,7 @@
DECLARE_HOOK_LIST(WindowDestroy, _notify_window_destroy) DECLARE_HOOK_LIST(WindowDestroy, _notify_window_destroy)
DECLARE_HOOK_LIST(WindowPosition, _notify_window_position) DECLARE_HOOK_LIST(WindowPosition, _notify_window_position)
DECLARE_HOOK_LIST(Close, _notify_screen_close)
int dixScreenRaiseWindowDestroy(WindowPtr pWin) int dixScreenRaiseWindowDestroy(WindowPtr pWin)
{ {
@ -72,3 +73,17 @@ void dixScreenRaiseWindowPosition(WindowPtr pWin, uint32_t x, uint32_t y)
if (pScreen->PositionWindow) if (pScreen->PositionWindow)
(*pScreen->PositionWindow) (pWin, x, y); (*pScreen->PositionWindow) (pWin, x, y);
} }
void dixScreenRaiseClose(ScreenPtr pScreen)
{
if (!pScreen)
return;
ARRAY_FOR_EACH(pScreen->_notify_screen_close, walk) {
if (walk.ptr->func)
walk.ptr->func(pScreen, walk.ptr->arg);
}
if (pScreen->CloseScreen)
(*pScreen->CloseScreen) (pScreen);
}

View File

@ -108,4 +108,36 @@ _X_EXPORT void dixScreenUnhookWindowPosition(ScreenPtr pScreen,
XorgWindowPositionProcPtr func, XorgWindowPositionProcPtr func,
void *arg); void *arg);
/* prototype of screen close notification handler */
typedef void (*XorgScreenCloseProcPtr)(ScreenPtr pScreen, void *arg);
/**
* @brief register a screen 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
* @param arg opaque pointer passed to the hook
*
* When registration fails, the server aborts.
*
**/
_X_EXPORT void dixScreenHookClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func,
void *arg);
/**
* @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 dixScreenHookClose
*
* Unregister a screen close notify hook registered via @ref dixScreenHookClose
**/
_X_EXPORT void dixScreenUnhookClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func,
void *arg);
#endif /* DIX_SCREEN_HOOKS_H */ #endif /* DIX_SCREEN_HOOKS_H */

View File

@ -573,6 +573,10 @@ typedef struct _Screen {
should NOT be touched outside of DIX core */ should NOT be touched outside of DIX core */
_SCREEN_HOOK_TYPE(_notify_window_position, XorgWindowPositionProcPtr, 4); _SCREEN_HOOK_TYPE(_notify_window_position, XorgWindowPositionProcPtr, 4);
/* additional screen close notify hooks (replaces wrapping CloseScreen)
should NOT be touched outside of DIX core */
_SCREEN_HOOK_TYPE(_notify_screen_close, XorgScreenCloseProcPtr, 8);
/* Pixmap procedures */ /* Pixmap procedures */
CreatePixmapProcPtr CreatePixmap; CreatePixmapProcPtr CreatePixmap;

View File

@ -213,5 +213,6 @@
/* announce server API features */ /* announce server API features */
#define XORG_API_DIX_SCREEN_HOOK_WINDOW_DESTROY 1 #define XORG_API_DIX_SCREEN_HOOK_WINDOW_DESTROY 1
#define XORG_API_DIX_SCREEN_HOOK_WINDOW_POSITION 1 #define XORG_API_DIX_SCREEN_HOOK_WINDOW_POSITION 1
#define XORG_API_DIX_SCREEN_HOOK_CLOSE 1
#endif /* _XORG_SERVER_H_ */ #endif /* _XORG_SERVER_H_ */