damage: 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 17:40:30 +02:00
parent 9577590f98
commit fa21d6fd0b
2 changed files with 6 additions and 12 deletions

View File

@ -1576,22 +1576,14 @@ damageSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap)
} }
} }
static Bool static void
damageDestroyWindow(WindowPtr pWindow) damageWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWindow)
{ {
DamagePtr pDamage; DamagePtr pDamage;
ScreenPtr pScreen = pWindow->drawable.pScreen;
Bool ret;
damageScrPriv(pScreen);
while ((pDamage = damageGetWinPriv(pWindow))) { while ((pDamage = damageGetWinPriv(pWindow))) {
DamageDestroy(pDamage); DamageDestroy(pDamage);
} }
unwrap(pScrPriv, pScreen, DestroyWindow);
ret = (*pScreen->DestroyWindow) (pWindow);
wrap(pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
return ret;
} }
static Bool static Bool
@ -1599,6 +1591,8 @@ damageCloseScreen(ScreenPtr pScreen)
{ {
damageScrPriv(pScreen); damageScrPriv(pScreen);
dixScreenUnhookWindowDestroy(pScreen, damageWindowDestroy);
unwrap(pScrPriv, pScreen, DestroyPixmap); unwrap(pScrPriv, pScreen, DestroyPixmap);
unwrap(pScrPriv, pScreen, CreateGC); unwrap(pScrPriv, pScreen, CreateGC);
unwrap(pScrPriv, pScreen, CopyWindow); unwrap(pScrPriv, pScreen, CopyWindow);
@ -1691,9 +1685,10 @@ DamageSetup(ScreenPtr pScreen)
pScrPriv->internalLevel = 0; pScrPriv->internalLevel = 0;
pScrPriv->pScreenDamage = 0; pScrPriv->pScreenDamage = 0;
dixScreenHookWindowDestroy(pScreen, damageWindowDestroy);
wrap(pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); wrap(pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
wrap(pScrPriv, pScreen, CreateGC, damageCreateGC); wrap(pScrPriv, pScreen, CreateGC, damageCreateGC);
wrap(pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
wrap(pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); wrap(pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
wrap(pScrPriv, pScreen, CopyWindow, damageCopyWindow); wrap(pScrPriv, pScreen, CopyWindow, damageCopyWindow);
wrap(pScrPriv, pScreen, CloseScreen, damageCloseScreen); wrap(pScrPriv, pScreen, CloseScreen, damageCloseScreen);

View File

@ -65,7 +65,6 @@ typedef struct _damageScrPriv {
CreateGCProcPtr CreateGC; CreateGCProcPtr CreateGC;
DestroyPixmapProcPtr DestroyPixmap; DestroyPixmapProcPtr DestroyPixmap;
SetWindowPixmapProcPtr SetWindowPixmap; SetWindowPixmapProcPtr SetWindowPixmap;
DestroyWindowProcPtr DestroyWindow;
CompositeProcPtr Composite; CompositeProcPtr Composite;
GlyphsProcPtr Glyphs; GlyphsProcPtr Glyphs;
AddTrapsProcPtr AddTraps; AddTrapsProcPtr AddTraps;