From 98563729320aadfb7a3cecc42e43b147fabb143d Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 18 Sep 2025 18:31:16 +0200 Subject: [PATCH] dix: add callback before ClientRec is being destroyed Existing client-state hook isn't sufficient for this, and so easy to be extended cleanly (*1). Adding a new callback is trivial and cheap, so preferring this way, instead of trying to tweak the existing hook for something it's never been designed for. *1) see discussion here: https://github.com/X11Libre/xserver/pull/1077 Signed-off-by: Enrico Weigelt, metux IT consult --- dix/client.c | 11 +++++++++++ dix/client_priv.h | 16 ++++++++++++++++ dix/dispatch.c | 2 ++ dix/meson.build | 1 + os/client_priv.h | 4 ++-- 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 dix/client.c create mode 100644 dix/client_priv.h diff --git a/dix/client.c b/dix/client.c new file mode 100644 index 000000000..2c32318ea --- /dev/null +++ b/dix/client.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + */ +#include + +#include + +#include "include/callback.h" + +CallbackListPtr ClientDestroyCallback = NULL; diff --git a/dix/client_priv.h b/dix/client_priv.h new file mode 100644 index 000000000..99eb4790f --- /dev/null +++ b/dix/client_priv.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + */ +#ifndef _XSERVER_DIX_CLIENT_PRIV_H +#define _XSERVER_DIX_CLIENT_PRIV_H + +#include "include/callback.h" + +/* + * called right before ClientRec is about to be destroyed, + * after resources have been freed. argument is ClientPtr + */ +extern CallbackListPtr ClientDestroyCallback; + +#endif /* _XSERVER_DIX_CLIENT_PRIV_H */ diff --git a/dix/dispatch.c b/dix/dispatch.c index 96ef412cc..0a7fc948c 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -103,6 +103,7 @@ Equipment Corporation. #include #include +#include "dix/client_priv.h" #include "dix/colormap_priv.h" #include "dix/cursor_priv.h" #include "dix/dix_priv.h" @@ -3550,6 +3551,7 @@ CloseDownClient(ClientPtr client) TouchListenerGone(client->clientAsMask); GestureListenerGone(client->clientAsMask); FreeClientResources(client); + CallCallbacks(&ClientDestroyCallback, client); /* Disable client ID tracking. This must be done after * ClientStateCallback. */ ReleaseClientIds(client); diff --git a/dix/meson.build b/dix/meson.build index 85f633421..0c3c662b9 100644 --- a/dix/meson.build +++ b/dix/meson.build @@ -1,5 +1,6 @@ srcs_dix = [ 'atom.c', + 'client.c', 'colormap.c', 'color.c', 'cursor.c', diff --git a/os/client_priv.h b/os/client_priv.h index 8bb0acf51..d0642f131 100644 --- a/os/client_priv.h +++ b/os/client_priv.h @@ -3,8 +3,8 @@ * Copyright © 2024 Enrico Weigelt, metux IT consult * Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). */ -#ifndef _XSERVER_DIX_CLIENT_PRIV_H -#define _XSERVER_DIX_CLIENT_PRIV_H +#ifndef _XSERVER_OS_CLIENT_PRIV_H +#define _XSERVER_OS_CLIENT_PRIV_H #include #include