From 06b1f9e2c052805788a63bef351510c0ac7d1c6f Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 20 Sep 2024 20:55:12 +0200 Subject: [PATCH] kdrive: xv: 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 --- hw/kdrive/src/kxv.c | 22 +++++++--------------- hw/kdrive/src/kxv.h | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c index 91e93ca64..1e0366be2 100644 --- a/hw/kdrive/src/kxv.c +++ b/hw/kdrive/src/kxv.c @@ -40,6 +40,7 @@ of the copyright holder. #include #include +#include "dix/screen_hooks_priv.h" #include "Xext/xvdix_priv.h" #include "kdrive.h" @@ -82,9 +83,10 @@ static int KdXVPutImage(DrawablePtr, XvPortPtr, GCPtr, static int KdXVQueryImageAttributes(XvPortPtr, XvImagePtr, CARD16 *, CARD16 *, int *, int *); +static void KdXVWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin); + /* ScreenRec fields */ -static Bool KdXVDestroyWindow(WindowPtr pWin); static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1); static void KdXVClipNotify(WindowPtr pWin, int dx, int dy); static Bool KdXVCloseScreen(ScreenPtr); @@ -139,13 +141,13 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num) if (!ScreenPriv) return FALSE; - ScreenPriv->DestroyWindow = pScreen->DestroyWindow; + dixScreenHookWindowDestroy(pScreen, KdXVWindowDestroy); + ScreenPriv->WindowExposures = pScreen->WindowExposures; ScreenPriv->ClipNotify = pScreen->ClipNotify; /* fprintf(stderr,"XV: Wrapping screen funcs\n"); */ - pScreen->DestroyWindow = KdXVDestroyWindow; pScreen->WindowExposures = KdXVWindowExposures; pScreen->ClipNotify = KdXVClipNotify; /* it will call KdCloseScreen() as it's the last act */ @@ -755,13 +757,10 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) /**** ScreenRec fields ****/ -static Bool -KdXVDestroyWindow(WindowPtr pWin) +static void +KdXVWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin) { - ScreenPtr pScreen = pWin->drawable.pScreen; - KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen); KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin); - int ret; while (WinPriv) { XvPortRecPrivatePtr pPriv = WinPriv->PortRec; @@ -779,12 +778,6 @@ KdXVDestroyWindow(WindowPtr pWin) } dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL); - - pScreen->DestroyWindow = ScreenPriv->DestroyWindow; - ret = (*pScreen->DestroyWindow) (pWin); - pScreen->DestroyWindow = KdXVDestroyWindow; - - return ret; } static void @@ -919,7 +912,6 @@ KdXVCloseScreen(ScreenPtr pScreen) if (!ScreenPriv) return TRUE; - pScreen->DestroyWindow = ScreenPriv->DestroyWindow; pScreen->WindowExposures = ScreenPriv->WindowExposures; pScreen->ClipNotify = ScreenPriv->ClipNotify; diff --git a/hw/kdrive/src/kxv.h b/hw/kdrive/src/kxv.h index 3ea150be8..7f01bb16e 100644 --- a/hw/kdrive/src/kxv.h +++ b/hw/kdrive/src/kxv.h @@ -151,7 +151,6 @@ Bool /*** These are DDX layer privates ***/ typedef struct { - DestroyWindowProcPtr DestroyWindow; ClipNotifyProcPtr ClipNotify; WindowExposuresProcPtr WindowExposures; } KdXVScreenRec, *KdXVScreenPtr;