(!1714) render: 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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-10-04 21:58:57 +02:00
parent c9680408a2
commit 2070c4b596
3 changed files with 5 additions and 18 deletions

View File

@ -60,7 +60,6 @@ typedef struct _AnimCur {
} AnimCurRec, *AnimCurPtr; } AnimCurRec, *AnimCurPtr;
typedef struct _AnimScrPriv { typedef struct _AnimScrPriv {
CloseScreenProcPtr CloseScreen;
CursorLimitsProcPtr CursorLimits; CursorLimitsProcPtr CursorLimits;
DisplayCursorProcPtr DisplayCursor; DisplayCursorProcPtr DisplayCursor;
SetCursorPositionProcPtr SetCursorPosition; SetCursorPositionProcPtr SetCursorPosition;
@ -84,13 +83,11 @@ static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func) #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt) #define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
static Bool static void AnimCurScreenClose(ScreenPtr pScreen, void *arg)
AnimCurCloseScreen(ScreenPtr pScreen)
{ {
AnimCurScreenPtr as = GetAnimCurScreen(pScreen); AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
Bool ret;
Unwrap(as, pScreen, CloseScreen); dixScreenUnhookClose(pScreen, AnimCurScreenClose, NULL);
Unwrap(as, pScreen, CursorLimits); Unwrap(as, pScreen, CursorLimits);
Unwrap(as, pScreen, DisplayCursor); Unwrap(as, pScreen, DisplayCursor);
@ -98,8 +95,6 @@ AnimCurCloseScreen(ScreenPtr pScreen)
Unwrap(as, pScreen, RealizeCursor); Unwrap(as, pScreen, RealizeCursor);
Unwrap(as, pScreen, UnrealizeCursor); Unwrap(as, pScreen, UnrealizeCursor);
Unwrap(as, pScreen, RecolorCursor); Unwrap(as, pScreen, RecolorCursor);
ret = (*pScreen->CloseScreen) (pScreen);
return ret;
} }
static void static void
@ -286,7 +281,7 @@ AnimCurInit(ScreenPtr pScreen)
as = GetAnimCurScreen(pScreen); as = GetAnimCurScreen(pScreen);
Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen); dixScreenHookClose(pScreen, AnimCurScreenClose, NULL);
Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits); Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor); Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);

View File

@ -76,15 +76,11 @@ picture_window_destructor(ScreenPtr pScreen, WindowPtr pWindow, void *arg)
} }
} }
static Bool static void PictureScreenClose(ScreenPtr pScreen, void *arg)
PictureCloseScreen(ScreenPtr pScreen)
{ {
PictureScreenPtr ps = GetPictureScreen(pScreen); PictureScreenPtr ps = GetPictureScreen(pScreen);
Bool ret;
int n; int n;
pScreen->CloseScreen = ps->CloseScreen;
ret = (*pScreen->CloseScreen) (pScreen);
PictureResetFilters(pScreen); PictureResetFilters(pScreen);
for (n = 0; n < ps->nformats; n++) for (n = 0; n < ps->nformats; n++)
if (ps->formats[n].type == PictTypeIndexed) if (ps->formats[n].type == PictTypeIndexed)
@ -93,7 +89,6 @@ PictureCloseScreen(ScreenPtr pScreen)
SetPictureScreen(pScreen, 0); SetPictureScreen(pScreen, 0);
free(ps->formats); free(ps->formats);
free(ps); free(ps);
return ret;
} }
static void static void
@ -684,12 +679,11 @@ PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
ps->subpixel = SubPixelUnknown; ps->subpixel = SubPixelUnknown;
ps->CloseScreen = pScreen->CloseScreen;
ps->StoreColors = pScreen->StoreColors; ps->StoreColors = pScreen->StoreColors;
pScreen->CloseScreen = PictureCloseScreen;
pScreen->StoreColors = PictureStoreColors; pScreen->StoreColors = PictureStoreColors;
dixScreenHookWindowDestroy(pScreen, picture_window_destructor, NULL); dixScreenHookWindowDestroy(pScreen, picture_window_destructor, NULL);
dixScreenHookClose(pScreen, PictureScreenClose, NULL);
if (!PictureSetDefaultFilters(pScreen)) { if (!PictureSetDefaultFilters(pScreen)) {
PictureResetFilters(pScreen); PictureResetFilters(pScreen);

View File

@ -294,8 +294,6 @@ typedef struct _PictureScreen {
GlyphsProcPtr Glyphs; /* unused */ GlyphsProcPtr Glyphs; /* unused */
CompositeRectsProcPtr CompositeRects; CompositeRectsProcPtr CompositeRects;
CloseScreenProcPtr CloseScreen;
StoreColorsProcPtr StoreColors; StoreColorsProcPtr StoreColors;
InitIndexedProcPtr InitIndexed; InitIndexedProcPtr InitIndexed;