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 c14783ef81
commit c335d5a92e
2 changed files with 7 additions and 12 deletions

View File

@ -24,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "dix/screen_hooks_priv.h"
#include "os/osdep.h" #include "os/osdep.h"
#include <X11/X.h> #include <X11/X.h>
@ -1576,22 +1577,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 +1592,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 +1686,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;