From 0a50759af412189ef67b8f4874427d0fa8d33ea4 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 23 Sep 2024 15:53:49 +0200 Subject: [PATCH] xfree86: dri: 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 --- dri3/dri3_priv.h | 1 - hw/xfree86/dri/dri.c | 33 +++++---------------------------- hw/xfree86/dri/dristruct.h | 1 - 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/dri3/dri3_priv.h b/dri3/dri3_priv.h index 801ad0660..08bdbacfd 100644 --- a/dri3/dri3_priv.h +++ b/dri3/dri3_priv.h @@ -46,7 +46,6 @@ typedef struct dri3_dmabuf_format { typedef struct dri3_screen_priv { CloseScreenProcPtr CloseScreen; ConfigNotifyProcPtr ConfigNotify; - DestroyWindowProcPtr DestroyWindow; Bool formats_cached; CARD32 num_formats; diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index 439296f5a..1461fca0e 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -48,6 +48,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include "dix/dix_priv.h" +#include "dix/screen_hooks_priv.h" #include "xf86.h" #include "xf86drm.h" @@ -644,7 +645,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) return TRUE; } -static Bool DRIDestroyWindow(WindowPtr pWin); +static void DRIWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin); Bool DRIFinishScreenInit(ScreenPtr pScreen) @@ -660,8 +661,7 @@ DRIFinishScreenInit(ScreenPtr pScreen) pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures; } - pDRIPriv->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = DRIDestroyWindow; + dixScreenHookWindowDestroy(pScreen, DRIWindowDestroy); pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, dri_crtc_notify); @@ -708,11 +708,8 @@ DRICloseScreen(ScreenPtr pScreen) pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; pDRIPriv->wrap.WindowExposures = NULL; } - if (pDRIPriv->DestroyWindow) { - pScreen->DestroyWindow = pDRIPriv->DestroyWindow; - pDRIPriv->DestroyWindow = NULL; - } + dixScreenUnhookWindowDestroy(pScreen, DRIWindowDestroy); xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify); if (pDRIInfo->wrap.CopyWindow) { @@ -1990,29 +1987,9 @@ DRITreeTraversal(WindowPtr pWin, void *data) return WT_WALKCHILDREN; } -static Bool -DRIDestroyWindow(WindowPtr pWin) +static void DRIWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin) { - ScreenPtr pScreen = pWin->drawable.pScreen; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - Bool retval = TRUE; - DRIDrawablePrivDestroy(pWin); - - /* call lower wrapped functions */ - if (pDRIPriv->DestroyWindow) { - /* unwrap */ - pScreen->DestroyWindow = pDRIPriv->DestroyWindow; - - /* call lower layers */ - retval = (*pScreen->DestroyWindow) (pWin); - - /* rewrap */ - pDRIPriv->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = DRIDestroyWindow; - } - - return retval; } void diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index 8241f60f7..52dfb7723 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -86,7 +86,6 @@ typedef struct _DRIScreenPrivRec { DrawablePtr fullscreen; /* pointer to fullscreen drawable */ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ DRIWrappedFuncsRec wrap; - DestroyWindowProcPtr DestroyWindow; DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ Bool createDummyCtx;