From e172253272924341f7d390a019666807a9e73799 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 8 Aug 2024 18:48:42 +0200 Subject: [PATCH] Xnest: fetch allowed screen depths from xcb screen info There's even no need to keep our own copies, since we can ask XCB's copy any time. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/Display.c | 20 ++++++++++---------- hw/xnest/Display.h | 2 -- hw/xnest/Init.c | 15 +++++++++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index 567e560ca..cc802bcfc 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -44,8 +44,6 @@ int xnestNumVisuals; int xnestDefaultVisualIndex; Colormap *xnestDefaultColormaps; static uint16_t xnestNumDefaultColormaps; -int *xnestDepths; -int xnestNumDepths; XPixmapFormatValues *xnestPixmapFormats; int xnestNumPixmapFormats; Drawable xnestDefaultDrawables[MAXDEPTH + 1]; @@ -68,7 +66,7 @@ xnestOpenDisplay(int argc, char *argv[]) { XVisualInfo vi; long mask; - int i, j; + int i; if (!xnestDoFullGeneration) return; @@ -128,9 +126,6 @@ xnestOpenDisplay(int argc, char *argv[]) xnestVisuals[i].visual->visualid); } - xnestDepths = XListDepths(xnestDisplay, xnestUpstreamInfo.screenId, - &xnestNumDepths); - xnestPixmapFormats = XListPixmapFormats(xnestDisplay, &xnestNumPixmapFormats); @@ -142,10 +137,14 @@ xnestOpenDisplay(int argc, char *argv[]) for (i = 0; i <= MAXDEPTH; i++) xnestDefaultDrawables[i] = XCB_WINDOW_NONE; - for (i = 0; i < xnestNumPixmapFormats; i++) - for (j = 0; j < xnestNumDepths; j++) + for (i = 0; i < xnestNumPixmapFormats; i++) { + xcb_depth_iterator_t depth_iter; + for (depth_iter = xcb_screen_allowed_depths_iterator(xnestUpstreamInfo.screenInfo); + depth_iter.rem; + xcb_depth_next(&depth_iter)) + { if (xnestPixmapFormats[i].depth == 1 || - xnestPixmapFormats[i].depth == xnestDepths[j]) { + xnestPixmapFormats[i].depth == depth_iter.data->depth) { uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn); xcb_create_pixmap(xnestUpstreamInfo.conn, xnestPixmapFormats[i].depth, @@ -154,6 +153,8 @@ xnestOpenDisplay(int argc, char *argv[]) 1, 1); xnestDefaultDrawables[xnestPixmapFormats[i].depth] = pixmap; } + } + } xnestBitmapGC = xcb_generate_id(xnestUpstreamInfo.conn); xcb_create_gc(xnestUpstreamInfo.conn, @@ -209,7 +210,6 @@ xnestCloseDisplay(void) free(xnestDefaultColormaps); XFree(xnestVisuals); - XFree(xnestDepths); XFree(xnestPixmapFormats); XCloseDisplay(xnestDisplay); } diff --git a/hw/xnest/Display.h b/hw/xnest/Display.h index 633012456..ed72c71c2 100644 --- a/hw/xnest/Display.h +++ b/hw/xnest/Display.h @@ -28,8 +28,6 @@ extern int xnestNumVisuals; extern int xnestDefaultVisualIndex; extern Colormap *xnestDefaultColormaps; extern int xnestNumDefaultClormaps; -extern int *xnestDepths; -extern int xnestNumDepths; extern XPixmapFormatValues *xnestPixmapFormats; extern int xnestNumPixmapFormats; extern Drawable xnestDefaultDrawables[MAXDEPTH + 1]; diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index 5e58a9bbe..b8056e32b 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -33,6 +33,7 @@ is" without express or implied warranty. #include "servermd.h" #include "dixfontstr.h" #include "extinit_priv.h" + #include "Xnest.h" #include "xnest-xcb.h" @@ -67,7 +68,7 @@ Bool noGlxExtension = FALSE; void InitOutput(ScreenInfo * screen_info, int argc, char *argv[]) { - int i, j; + int i; xnestOpenDisplay(argc, argv); @@ -76,10 +77,14 @@ InitOutput(ScreenInfo * screen_info, int argc, char *argv[]) screen_info->bitmapScanlinePad = xnestUpstreamInfo.setup->bitmap_format_scanline_pad; screen_info->bitmapBitOrder = xnestUpstreamInfo.setup->bitmap_format_bit_order; screen_info->numPixmapFormats = 0; - for (i = 0; i < xnestNumPixmapFormats; i++) - for (j = 0; j < xnestNumDepths; j++) + for (i = 0; i < xnestNumPixmapFormats; i++) { + xcb_depth_iterator_t depth_iter; + for (depth_iter = xcb_screen_allowed_depths_iterator(xnestUpstreamInfo.screenInfo); + depth_iter.rem; + xcb_depth_next(&depth_iter)) + { if ((xnestPixmapFormats[i].depth == 1) || - (xnestPixmapFormats[i].depth == xnestDepths[j])) { + (xnestPixmapFormats[i].depth == depth_iter.data->depth)) { screen_info->formats[screen_info->numPixmapFormats].depth = xnestPixmapFormats[i].depth; screen_info->formats[screen_info->numPixmapFormats].bitsPerPixel = @@ -89,6 +94,8 @@ InitOutput(ScreenInfo * screen_info, int argc, char *argv[]) screen_info->numPixmapFormats++; break; } + } + } xnestFontPrivateIndex = xfont2_allocate_font_private_index();