mi: decouple miCreateScreenResources from pScreen->{width,height}

This allows pScreen->{width,height} to be changed to smaller values
after miScreenInit() is called but before pScreen is further set up
/ used by dix, so that the screen size can be fit to the mode of
choice even when it does not have the maximum width and/or height
among its peers.

XGetImage() for one will fail once the screen is change back to a
bigger size with xrandr, which prevents e.g. x11vnc to work on the
server.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/854>
This commit is contained in:
Tom Yan 2022-01-20 22:25:07 +08:00 committed by Alan Coopersmith
parent aa3f5023e3
commit 7c5b5642b2

View File

@ -55,6 +55,8 @@ from The Open Group.
typedef struct {
void *pbits; /* pointer to framebuffer */
int width; /* delta to add to a framebuffer addr to move one row down */
int xsize;
int ysize;
} miScreenInitParmsRec, *miScreenInitParmsPtr;
/* this plugs into pScreen->ModifyPixmapHeader */
@ -166,8 +168,8 @@ miCreateScreenResources(ScreenPtr pScreen)
if (!pPixmap)
return FALSE;
if (!(*pScreen->ModifyPixmapHeader) (pPixmap, pScreen->width,
pScreen->height,
if (!(*pScreen->ModifyPixmapHeader) (pPixmap, pScrInitParms->xsize,
pScrInitParms->ysize,
pScreen->rootDepth,
BitsPerPixel(pScreen->rootDepth),
PixmapBytePad(pScrInitParms->width,
@ -185,7 +187,7 @@ miCreateScreenResources(ScreenPtr pScreen)
}
static Bool
miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits)
miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits, int xsize, int ysize)
{
miScreenInitParmsPtr pScrInitParms;
@ -198,6 +200,8 @@ miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits)
return FALSE;
pScrInitParms->pbits = pbits;
pScrInitParms->width = width;
pScrInitParms->xsize = xsize;
pScrInitParms->ysize = ysize;
pScreen->devPrivate = (void *) pScrInitParms;
return TRUE;
}
@ -291,7 +295,7 @@ miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */
miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS);
return miScreenDevPrivateInit(pScreen, width, pbits);
return miScreenDevPrivateInit(pScreen, width, pbits, xsize, ysize);
}
DevPrivateKeyRec miZeroLineScreenKeyRec;