mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
dix: add per-screen window destructor hook
Right now, extension specific window destruction procedures are implemented by wrapping the ScreenRec's DestroyWindow() proc pointer: the extensions are storing the original pointer in their private data and putting in their own one. On each call, their proc restores the original one, calls it, and switches back again. When multiple extensions doing so, they're forming a kind of daisy chain. (the same is done for lots of other procs) While that approach is looking nice and elegant on the drawing board, it's complicated, dangerous like a chainsaw and makes debugging hard, leading to pretty blurred API borders. This commit introduces a simple approach for letting extension hook into the window destruction safely, w/o having to care much about side effects with the call chain. Extensions now can simply register their destructor proc (and an opaque pointer) and get called back - w/o ever having to mess with the ScreenRec's internal structures. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -490,8 +490,17 @@ typedef void (*DPMSProcPtr)(ScreenPtr pScreen, int level);
|
||||
required. Unwrap occurs at the top of each function, just after
|
||||
entry, and Wrap occurs at the bottom of each function, just
|
||||
before returning.
|
||||
|
||||
DestroyWindow() should NOT be wrapped anymore
|
||||
use dixScreenHookWindowDestroy() instead.
|
||||
*/
|
||||
|
||||
#define _SCREEN_HOOK_TYPE(NAME, FUNCTYPE, ARRSIZE) \
|
||||
struct { \
|
||||
FUNCTYPE func; \
|
||||
void *arg; \
|
||||
} NAME[ARRSIZE];
|
||||
|
||||
typedef struct _Screen {
|
||||
int myNum; /* index of this instance in Screens[] */
|
||||
ATOM id;
|
||||
@@ -658,6 +667,10 @@ typedef struct _Screen {
|
||||
ReplaceScanoutPixmapProcPtr ReplaceScanoutPixmap;
|
||||
XYToWindowProcPtr XYToWindow;
|
||||
DPMSProcPtr DPMS;
|
||||
|
||||
/* additional window destructors (replaces wrapping DestroyWindow).
|
||||
should NOT be touched outside of DIX core */
|
||||
CallbackListPtr hookWindowDestroy;
|
||||
} ScreenRec;
|
||||
|
||||
static inline RegionPtr
|
||||
|
||||
@@ -214,4 +214,7 @@
|
||||
/* byte order */
|
||||
#mesondefine X_BYTE_ORDER
|
||||
|
||||
/* announce server API features */
|
||||
#define XORG_API_DIX_SCREEN_HOOK_WINDOW_DESTROY 1
|
||||
|
||||
#endif /* _XORG_SERVER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user