xfree86: sbus: 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 2025-04-29 16:31:47 +02:00
parent 57b9155a7d
commit 0fb851e46f

View File

@ -624,7 +624,6 @@ static DevPrivateKeyRec sbusPaletteKeyRec;
typedef struct _sbusCmap { typedef struct _sbusCmap {
sbusDevicePtr psdp; sbusDevicePtr psdp;
CloseScreenProcPtr CloseScreen;
Bool origCmapValid; Bool origCmapValid;
unsigned char origRed[16]; unsigned char origRed[16];
unsigned char origGreen[16]; unsigned char origGreen[16];
@ -668,13 +667,18 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
free(data); free(data);
} }
static Bool static void xf86SbusCmapCloseScreen(CallbackListPtr *pcbl,
xf86SbusCmapCloseScreen(ScreenPtr pScreen) ScreenPtr pScreen, void *unused)
{ {
sbusCmapPtr cmap; sbusCmapPtr cmap;
struct fbcmap fbcmap; struct fbcmap fbcmap;
dixScreenUnhook(pScreen, xf86SbusCmapCloseScreen);
cmap = SBUSCMAPPTR(pScreen); cmap = SBUSCMAPPTR(pScreen);
if (!cmap)
return;
if (cmap->origCmapValid) { if (cmap->origCmapValid) {
fbcmap.index = 0; fbcmap.index = 0;
fbcmap.count = 16; fbcmap.count = 16;
@ -683,9 +687,8 @@ xf86SbusCmapCloseScreen(ScreenPtr pScreen)
fbcmap.blue = cmap->origBlue; fbcmap.blue = cmap->origBlue;
ioctl(cmap->psdp->fd, FBIOPUTCMAP, &fbcmap); ioctl(cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
} }
pScreen->CloseScreen = cmap->CloseScreen;
free(cmap); free(cmap);
return (*pScreen->CloseScreen) (pScreen); dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, NULL);
} }
Bool Bool
@ -722,8 +725,7 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
data[1] = 255; data[1] = 255;
} }
ioctl(psdp->fd, FBIOPUTCMAP, &fbcmap); ioctl(psdp->fd, FBIOPUTCMAP, &fbcmap);
cmap->CloseScreen = pScreen->CloseScreen; dixScreenHookClose(pScreen, xf86SbusCmapCloseScreen);
pScreen->CloseScreen = xf86SbusCmapCloseScreen;
return xf86HandleColormaps(pScreen, 256, 8, return xf86HandleColormaps(pScreen, 256, 8,
xf86SbusCmapLoadPalette, NULL, 0); xf86SbusCmapLoadPalette, NULL, 0);
} }