From b0f1bc92e5102233b45088bf8cb03b97ef9f8a00 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 29 Apr 2025 10:53:37 +0200 Subject: [PATCH] xfree86: randr: 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/xf86RandR.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 9f48e2c15..744ac7337 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -28,6 +28,7 @@ #include #include "dix/input_priv.h" +#include "dix/screen_hooks_priv.h" #include "os.h" #include "globals.h" @@ -40,7 +41,6 @@ #include "inputstr.h" typedef struct _xf86RandRInfo { - CloseScreenProcPtr CloseScreen; int virtualX; int virtualY; int mmWidth; @@ -341,19 +341,22 @@ xf86RandRSetConfig(ScreenPtr pScreen, /* * Reset size back to original */ -static Bool -xf86RandRCloseScreen(ScreenPtr pScreen) +static void xf86RandRCloseScreen(CallbackListPtr *pcbl, + ScreenPtr pScreen, void *unused) { ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen); + if (!scrp) + return; + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); scrp->virtualX = pScreen->width = randrp->virtualX; scrp->virtualY = pScreen->height = randrp->virtualY; scrp->currentMode = scrp->modes; - pScreen->CloseScreen = randrp->CloseScreen; + + dixScreenUnhookClose(pScreen, xf86RandRCloseScreen); free(randrp); dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL); - return (*pScreen->CloseScreen) (pScreen); } Rotation @@ -438,8 +441,7 @@ xf86RandRInit(ScreenPtr pScreen) randrp->mmWidth = pScreen->mmWidth; randrp->mmHeight = pScreen->mmHeight; - randrp->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = xf86RandRCloseScreen; + dixScreenHookClose(pScreen, xf86RandRCloseScreen); randrp->rotation = RR_Rotate_0;