From f061315afa8bc2bc20716fcee79804f311a115b0 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 20 Sep 2024 20:30:33 +0200 Subject: [PATCH] rootless: use window destructor hook Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new window destructor hook instead. Signed-off-by: Enrico Weigelt, metux IT consult --- miext/rootless/rootlessCommon.h | 1 - miext/rootless/rootlessScreen.c | 4 +++- miext/rootless/rootlessWindow.c | 21 ++++++--------------- miext/rootless/rootlessWindow.h | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h index 40400b395..1e236bb9d 100644 --- a/miext/rootless/rootlessCommon.h +++ b/miext/rootless/rootlessCommon.h @@ -84,7 +84,6 @@ typedef struct _RootlessScreenRec { CloseScreenProcPtr CloseScreen; CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; RealizeWindowProcPtr RealizeWindow; UnrealizeWindowProcPtr UnrealizeWindow; MoveWindowProcPtr MoveWindow; diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c index ddb1cf607..9d778249b 100644 --- a/miext/rootless/rootlessScreen.c +++ b/miext/rootless/rootlessScreen.c @@ -37,6 +37,7 @@ #include #include "dix/colormap_priv.h" +#include "dix/screen_hooks_priv.h" #include "mi/mi_priv.h" #include "scrnintstr.h" @@ -649,6 +650,8 @@ RootlessWrap(ScreenPtr pScreen) { RootlessScreenRec *s = SCREENREC(pScreen); + dixScreenHookWindowDestroy(pScreen, RootlessWindowDestroy); + #define WRAP(a) \ if (pScreen->a) { \ s->a = pScreen->a; \ @@ -666,7 +669,6 @@ RootlessWrap(ScreenPtr pScreen) WRAP(GetImage); WRAP(SourceValidate); WRAP(CreateWindow); - WRAP(DestroyWindow); WRAP(RealizeWindow); WRAP(UnrealizeWindow); WRAP(MoveWindow); diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 6d6c596f4..aa7fa930c 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -36,9 +36,10 @@ #include #include +#include "dix/dix_priv.h" +#include "dix/screen_hooks_priv.h" #include "fb/fb_priv.h" #include "mi/mi_priv.h" -#include "dix_priv.h" #ifdef __APPLE__ #include @@ -189,24 +190,14 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec) } /* - * RootlessDestroyWindow - * Destroy the physical window associated with the given window. + * @brief window destructor: remove physical window associated with given window */ -Bool -RootlessDestroyWindow(WindowPtr pWin) +void +RootlessWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin) { RootlessWindowRec *winRec = WINREC(pWin); - Bool result; - - if (winRec != NULL) { + if (winRec != NULL) RootlessDestroyFrame(pWin, winRec); - } - - SCREEN_UNWRAP(pWin->drawable.pScreen, DestroyWindow); - result = pWin->drawable.pScreen->DestroyWindow(pWin); - SCREEN_WRAP(pWin->drawable.pScreen, DestroyWindow); - - return result; } static Bool diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h index 4fd34d54d..dc7de79db 100644 --- a/miext/rootless/rootlessWindow.h +++ b/miext/rootless/rootlessWindow.h @@ -37,7 +37,7 @@ #include "rootlessCommon.h" Bool RootlessCreateWindow(WindowPtr pWin); -Bool RootlessDestroyWindow(WindowPtr pWin); +void RootlessWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin); void RootlessSetShape(WindowPtr pWin, int kind);