Skip to content

Commit bc53cfa

Browse files
committed
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: #1077 Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
1 parent 19527ac commit bc53cfa

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

dix/client.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: MIT OR X11
2+
*
3+
* Copyright © 2024 Enrico Weigelt, metux IT consult <[email protected]>
4+
*/
5+
#include <dix-config.h>
6+
7+
#include <stddef.h>
8+
9+
#include "include/callback.h"
10+
11+
CallbackListPtr ClientDestroyCallback = NULL;

dix/client_priv.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: MIT OR X11
2+
*
3+
* Copyright © 2024 Enrico Weigelt, metux IT consult <[email protected]>
4+
*/
5+
#ifndef _XSERVER_DIX_CLIENT_PRIV_H
6+
#define _XSERVER_DIX_CLIENT_PRIV_H
7+
8+
#include "include/callback.h"
9+
10+
/*
11+
* called right before ClientRec is about to be destroyed,
12+
* after resources have been freed. argument is ClientPtr
13+
*/
14+
extern CallbackListPtr ClientDestroyCallback;
15+
16+
#endif /* _XSERVER_DIX_CLIENT_PRIV_H */

dix/dispatch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Equipment Corporation.
103103
#include <X11/fonts/fontstruct.h>
104104
#include <X11/fonts/libxfont2.h>
105105

106+
#include "dix/client_priv.h"
106107
#include "dix/colormap_priv.h"
107108
#include "dix/cursor_priv.h"
108109
#include "dix/dix_priv.h"
@@ -3643,6 +3644,7 @@ CloseDownClient(ClientPtr client)
36433644
TouchListenerGone(client->clientAsMask);
36443645
GestureListenerGone(client->clientAsMask);
36453646
FreeClientResources(client);
3647+
CallCallbacks(&ClientDestroyCallback, client);
36463648
/* Disable client ID tracking. This must be done after
36473649
* ClientStateCallback. */
36483650
ReleaseClientIds(client);

dix/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
srcs_dix = [
22
'atom.c',
3+
'client.c',
34
'colormap.c',
45
'color.c',
56
'cursor.c',

os/client_priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Copyright © 2024 Enrico Weigelt, metux IT consult <[email protected]>
44
* Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
55
*/
6-
#ifndef _XSERVER_DIX_CLIENT_PRIV_H
7-
#define _XSERVER_DIX_CLIENT_PRIV_H
6+
#ifndef _XSERVER_OS_CLIENT_PRIV_H
7+
#define _XSERVER_OS_CLIENT_PRIV_H
88

99
#include <sys/types.h>
1010
#include <X11/Xdefs.h>

0 commit comments

Comments
 (0)