From 1c8dc9e3296ce5d41e09f731362d6c59f2274010 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 23 Sep 2024 17:42:04 +0200 Subject: [PATCH] (!1714) mi: overlay: 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 --- mi/mioverlay.c | 23 +++++------------------ mi/miscrinit.c | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/mi/mioverlay.c b/mi/mioverlay.c index 5e380cd7e..15bf4d3dc 100644 --- a/mi/mioverlay.c +++ b/mi/mioverlay.c @@ -46,7 +46,6 @@ typedef struct { typedef struct { CloseScreenProcPtr CloseScreen; CreateWindowProcPtr CreateWindow; - DestroyWindowProcPtr DestroyWindow; UnrealizeWindowProcPtr UnrealizeWindow; RealizeWindowProcPtr RealizeWindow; miOverlayTransFunc MakeTransparent; @@ -69,7 +68,7 @@ static Bool CollectUnderlayChildrenRegions(WindowPtr, RegionPtr); static Bool miOverlayCloseScreen(ScreenPtr); static Bool miOverlayCreateWindow(WindowPtr); -static Bool miOverlayDestroyWindow(WindowPtr); +static void miOverlayWindowDestroy(ScreenPtr pScreen, WindowPtr, void *arg); static Bool miOverlayUnrealizeWindow(WindowPtr); static Bool miOverlayRealizeWindow(WindowPtr); static void miOverlayMarkWindow(WindowPtr); @@ -126,6 +125,7 @@ miInitOverlay(ScreenPtr pScreen, return FALSE; dixSetPrivate(&pScreen->devPrivates, miOverlayScreenKey, pScreenPriv); + dixScreenHookWindowDestroy(pScreen, miOverlayWindowDestroy, NULL); pScreenPriv->InOverlay = inOverlayFunc; pScreenPriv->MakeTransparent = transFunc; @@ -133,13 +133,11 @@ miInitOverlay(ScreenPtr pScreen, pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CreateWindow = pScreen->CreateWindow; - pScreenPriv->DestroyWindow = pScreen->DestroyWindow; pScreenPriv->UnrealizeWindow = pScreen->UnrealizeWindow; pScreenPriv->RealizeWindow = pScreen->RealizeWindow; pScreen->CloseScreen = miOverlayCloseScreen; pScreen->CreateWindow = miOverlayCreateWindow; - pScreen->DestroyWindow = miOverlayDestroyWindow; pScreen->UnrealizeWindow = miOverlayUnrealizeWindow; pScreen->RealizeWindow = miOverlayRealizeWindow; @@ -164,10 +162,10 @@ static Bool miOverlayCloseScreen(ScreenPtr pScreen) { miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen); + dixScreenUnhookWindowDestroy(pScreen, miOverlayWindowDestroy, NULL); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->CreateWindow = pScreenPriv->CreateWindow; - pScreen->DestroyWindow = pScreenPriv->DestroyWindow; pScreen->UnrealizeWindow = pScreenPriv->UnrealizeWindow; pScreen->RealizeWindow = pScreenPriv->RealizeWindow; @@ -226,13 +224,10 @@ miOverlayCreateWindow(WindowPtr pWin) return TRUE; } -static Bool -miOverlayDestroyWindow(WindowPtr pWin) +static void +miOverlayWindowDestroy(ScreenPtr pScreen, WindowPtr pWin, void *arg) { - ScreenPtr pScreen = pWin->drawable.pScreen; - miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen); miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin); - Bool result = TRUE; if (pTree) { if (pTree->prevSib) @@ -249,14 +244,6 @@ miOverlayDestroyWindow(WindowPtr pWin) RegionUninit(&(pTree->clipList)); free(pTree); } - - if (pScreenPriv->DestroyWindow) { - pScreen->DestroyWindow = pScreenPriv->DestroyWindow; - result = (*pScreen->DestroyWindow) (pWin); - pScreen->DestroyWindow = miOverlayDestroyWindow; - } - - return result; } static Bool diff --git a/mi/miscrinit.c b/mi/miscrinit.c index b3167571d..7208dcec2 100644 --- a/mi/miscrinit.c +++ b/mi/miscrinit.c @@ -265,7 +265,7 @@ miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */ pScreen->SaveScreen = miSaveScreen; /* GetImage, GetSpans */ pScreen->SourceValidate = miSourceValidate; - /* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */ + /* CreateWindow, PositionWindow, ChangeWindowAttributes */ /* RealizeWindow, UnrealizeWindow */ pScreen->ValidateTree = miValidateTree; pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;