From 7c5b5642b2abf7d67e1ce04b75d85915faa34f4c Mon Sep 17 00:00:00 2001 From: Tom Yan Date: Thu, 20 Jan 2022 22:25:07 +0800 Subject: [PATCH] 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: --- mi/miscrinit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mi/miscrinit.c b/mi/miscrinit.c index f375d19fa..2030674a9 100644 --- a/mi/miscrinit.c +++ b/mi/miscrinit.c @@ -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;