From c90974c00df12bf0c08311cc382cf72ede29aeb5 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 18 Sep 2024 16:17:05 +0200 Subject: [PATCH] xnest: add pixmap depths to global depth list Right now, we're only registering the depths of our visuals, which are mirroring upstream's visuals. But forgotten to register the pixmap depths that don't have an assiocated visual. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Screen.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 6b4d2e19b..4a743ef2a 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -137,29 +137,27 @@ static miPointerSpriteFuncRec xnestPointerSpriteFuncs = { xnestDeviceCursorCleanup }; -static int add_depth_visual(DepthPtr depths, int numDepths, int nplanes, VisualID vid) +static DepthPtr add_depth(DepthPtr depths, int *numDepths, int nplanes) { - DepthPtr walk = NULL; + int num = *numDepths; - for (int j = 0; j < numDepths; j++) - if (depths[j].depth == nplanes) { - walk = &depths[j]; - break; - } + for (int j = 0; j < num; j++) + if (depths[j].depth == nplanes) + return &depths[j]; - if (!walk) { - walk = &depths[numDepths++]; - walk->depth = nplanes; - walk->numVids = 0; - walk->vids = (VisualID *) malloc(MAXVISUALSPERDEPTH * sizeof(VisualID)); - } - if (walk->numVids >= MAXVISUALSPERDEPTH) { - FatalError("Visual table overflow"); - } + depths[num].depth = nplanes; + if (!(depths[num].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID)))) + FatalError("memory allocation failed"); + + (*numDepths)++; + return &depths[num]; +} + +static void add_depth_visual(DepthPtr depths, int *numDepths, int nplanes, VisualID vid) +{ + DepthPtr walk = add_depth(depths, numDepths, nplanes); walk->vids[walk->numVids] = vid; walk->numVids++; - - return numDepths; } Bool @@ -192,7 +190,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) int numVisuals = 0; VisualPtr visuals = calloc(1, sizeof(VisualRec)); - int numDepths = 1; + int numDepths = 0; DepthPtr depths = calloc(MAXDEPTH, sizeof(DepthRec)); if (!visuals || !depths) { @@ -206,9 +204,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) else xnestVisualMap = reallocarray(xnestVisualMap, xnestNumVisualMap+1, sizeof(xnest_visual_t)); - depths[0].depth = 1; - depths[0].numVids = 0; - depths[0].vids = calloc(MAXVISUALSPERDEPTH, sizeof(VisualID)); + add_depth(depths, &numDepths, 1); + + for (int i=0; iroot, xnestVisualMap[xnestNumVisualMap].upstreamVisual->visual_id); - numDepths = add_depth_visual(depths, numDepths, visuals[numVisuals].nplanes, visuals[numVisuals].vid); + add_depth_visual(depths, &numDepths, visuals[numVisuals].nplanes, visuals[numVisuals].vid); if (xnestUserDefaultClass || xnestUserDefaultDepth) { if ((!xnestDefaultClass || visuals[numVisuals].class == xnestDefaultClass) &&