From 0defaf5fdc1a2e231e62b549a7518ed84ea5a0aa Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 29 Apr 2025 10:49:38 +0200 Subject: [PATCH] xfree86: dga: use CloseScreen hook Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new screen close notify hook instead. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86DGA.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 2482530a1..a128f3b26 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -50,6 +50,7 @@ #include "dix/dix_priv.h" #include "dix/eventconvert.h" #include "dix/exevents_priv.h" +#include "dix/screen_hooks_priv.h" #include "mi/mi_priv.h" #include "xf86.h" @@ -84,7 +85,7 @@ static DevPrivateKeyRec DGAScreenKeyRec; #define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec) -static Bool DGACloseScreen(ScreenPtr pScreen); +static void DGACloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused); static void DGADestroyColormap(ColormapPtr pmap); static void DGAInstallColormap(ColormapPtr pmap); static void DGAUninstallColormap(ColormapPtr pmap); @@ -111,7 +112,6 @@ typedef struct { ScrnInfoPtr pScrn; int numModes; DGAModePtr modes; - CloseScreenProcPtr CloseScreen; DestroyColormapProcPtr DestroyColormap; InstallColormapProcPtr InstallColormap; UninstallColormapProcPtr UninstallColormap; @@ -149,8 +149,7 @@ DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num) if (!(pScreenPriv = (DGAScreenPtr) malloc(sizeof(DGAScreenRec)))) return FALSE; dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv); - pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = DGACloseScreen; + dixScreenHookClose(pScreen, DGACloseScreen); pScreenPriv->DestroyColormap = pScreen->DestroyColormap; pScreen->DestroyColormap = DGADestroyColormap; pScreenPriv->InstallColormap = pScreen->InstallColormap; @@ -264,23 +263,24 @@ FreeMarkedVisuals(ScreenPtr pScreen) } } -static Bool -DGACloseScreen(ScreenPtr pScreen) +static void DGACloseScreen(CallbackListPtr *pcbl, + ScreenPtr pScreen, void *unused) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + if (!pScreenPriv) + return; mieqSetHandler(ET_DGAEvent, NULL); pScreenPriv->pScrn->SetDGAMode(pScreenPriv->pScrn, 0, NULL); FreeMarkedVisuals(pScreen); - pScreen->CloseScreen = pScreenPriv->CloseScreen; + dixScreenUnhookClose(pScreen, DGACloseScreen); pScreen->DestroyColormap = pScreenPriv->DestroyColormap; pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->UninstallColormap = pScreenPriv->UninstallColormap; free(pScreenPriv); - - return ((*pScreen->CloseScreen) (pScreen)); + dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, NULL); } static void