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 d61de13690
commit a9d35bcdd2
3 changed files with 7 additions and 18 deletions

View File

@ -38,6 +38,7 @@
#include "dix/cursor_priv.h" #include "dix/cursor_priv.h"
#include "dix/input_priv.h" #include "dix/input_priv.h"
#include "dix/screen_hooks_priv.h"
#include "servermd.h" #include "servermd.h"
#include "scrnintstr.h" #include "scrnintstr.h"
@ -61,7 +62,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;
@ -85,13 +85,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(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
AnimCurCloseScreen(ScreenPtr pScreen)
{ {
AnimCurScreenPtr as = GetAnimCurScreen(pScreen); AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
Bool ret;
Unwrap(as, pScreen, CloseScreen); dixScreenUnhookClose(pScreen, AnimCurScreenClose);
Unwrap(as, pScreen, CursorLimits); Unwrap(as, pScreen, CursorLimits);
Unwrap(as, pScreen, DisplayCursor); Unwrap(as, pScreen, DisplayCursor);
@ -99,8 +97,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
@ -287,7 +283,7 @@ AnimCurInit(ScreenPtr pScreen)
as = GetAnimCurScreen(pScreen); as = GetAnimCurScreen(pScreen);
Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen); dixScreenHookClose(pScreen, AnimCurScreenClose);
Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits); Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor); Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);

View File

@ -77,15 +77,11 @@ picture_window_destructor(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pW
} }
} }
static Bool static void PictureScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
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)
@ -94,7 +90,7 @@ PictureCloseScreen(ScreenPtr pScreen)
SetPictureScreen(pScreen, 0); SetPictureScreen(pScreen, 0);
free(ps->formats); free(ps->formats);
free(ps); free(ps);
return ret; dixScreenUnhookClose(pScreen, PictureScreenClose);
} }
static void static void
@ -685,12 +681,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); dixScreenHookWindowDestroy(pScreen, picture_window_destructor);
dixScreenHookClose(pScreen, PictureScreenClose);
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;