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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-08-08 18:48:42 +02:00
parent 07829c18f8
commit e172253272
3 changed files with 21 additions and 16 deletions

View File

@ -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);
}

View File

@ -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];

View File

@ -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();