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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-09-20 20:55:12 +02:00
parent f061315afa
commit 06b1f9e2c0
2 changed files with 7 additions and 16 deletions

View File

@ -40,6 +40,7 @@ of the copyright holder.
#include <X11/extensions/Xv.h> #include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h> #include <X11/extensions/Xvproto.h>
#include "dix/screen_hooks_priv.h"
#include "Xext/xvdix_priv.h" #include "Xext/xvdix_priv.h"
#include "kdrive.h" #include "kdrive.h"
@ -82,9 +83,10 @@ static int KdXVPutImage(DrawablePtr, XvPortPtr, GCPtr,
static int KdXVQueryImageAttributes(XvPortPtr, XvImagePtr, static int KdXVQueryImageAttributes(XvPortPtr, XvImagePtr,
CARD16 *, CARD16 *, int *, int *); CARD16 *, CARD16 *, int *, int *);
static void KdXVWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin);
/* ScreenRec fields */ /* ScreenRec fields */
static Bool KdXVDestroyWindow(WindowPtr pWin);
static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1); static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1);
static void KdXVClipNotify(WindowPtr pWin, int dx, int dy); static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
static Bool KdXVCloseScreen(ScreenPtr); static Bool KdXVCloseScreen(ScreenPtr);
@ -139,13 +141,13 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
if (!ScreenPriv) if (!ScreenPriv)
return FALSE; return FALSE;
ScreenPriv->DestroyWindow = pScreen->DestroyWindow; dixScreenHookWindowDestroy(pScreen, KdXVWindowDestroy);
ScreenPriv->WindowExposures = pScreen->WindowExposures; ScreenPriv->WindowExposures = pScreen->WindowExposures;
ScreenPriv->ClipNotify = pScreen->ClipNotify; ScreenPriv->ClipNotify = pScreen->ClipNotify;
/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */ /* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
pScreen->DestroyWindow = KdXVDestroyWindow;
pScreen->WindowExposures = KdXVWindowExposures; pScreen->WindowExposures = KdXVWindowExposures;
pScreen->ClipNotify = KdXVClipNotify; pScreen->ClipNotify = KdXVClipNotify;
/* it will call KdCloseScreen() as it's the last act */ /* it will call KdCloseScreen() as it's the last act */
@ -755,13 +757,10 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
/**** ScreenRec fields ****/ /**** ScreenRec fields ****/
static Bool static void
KdXVDestroyWindow(WindowPtr pWin) 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); KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin);
int ret;
while (WinPriv) { while (WinPriv) {
XvPortRecPrivatePtr pPriv = WinPriv->PortRec; XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
@ -779,12 +778,6 @@ KdXVDestroyWindow(WindowPtr pWin)
} }
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL); dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow) (pWin);
pScreen->DestroyWindow = KdXVDestroyWindow;
return ret;
} }
static void static void
@ -919,7 +912,6 @@ KdXVCloseScreen(ScreenPtr pScreen)
if (!ScreenPriv) if (!ScreenPriv)
return TRUE; return TRUE;
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
pScreen->WindowExposures = ScreenPriv->WindowExposures; pScreen->WindowExposures = ScreenPriv->WindowExposures;
pScreen->ClipNotify = ScreenPriv->ClipNotify; pScreen->ClipNotify = ScreenPriv->ClipNotify;

View File

@ -151,7 +151,6 @@ Bool
/*** These are DDX layer privates ***/ /*** These are DDX layer privates ***/
typedef struct { typedef struct {
DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify; ClipNotifyProcPtr ClipNotify;
WindowExposuresProcPtr WindowExposures; WindowExposuresProcPtr WindowExposures;
} KdXVScreenRec, *KdXVScreenPtr; } KdXVScreenRec, *KdXVScreenPtr;