Xnest: fetch supported pixmap formats from xcb setup data

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-09 13:01:57 +02:00
parent e172253272
commit a05b912d06
3 changed files with 15 additions and 17 deletions

View File

@ -44,7 +44,6 @@ int xnestNumVisuals;
int xnestDefaultVisualIndex;
Colormap *xnestDefaultColormaps;
static uint16_t xnestNumDefaultColormaps;
XPixmapFormatValues *xnestPixmapFormats;
int xnestNumPixmapFormats;
Drawable xnestDefaultDrawables[MAXDEPTH + 1];
Pixmap xnestIconBitmap;
@ -126,9 +125,6 @@ xnestOpenDisplay(int argc, char *argv[])
xnestVisuals[i].visual->visualid);
}
xnestPixmapFormats = XListPixmapFormats(xnestDisplay,
&xnestNumPixmapFormats);
if (xnestParentWindow != (Window) 0)
xnestEventMask = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
else
@ -137,21 +133,22 @@ xnestOpenDisplay(int argc, char *argv[])
for (i = 0; i <= MAXDEPTH; i++)
xnestDefaultDrawables[i] = XCB_WINDOW_NONE;
for (i = 0; i < xnestNumPixmapFormats; i++) {
xcb_format_t *fmt = xcb_setup_pixmap_formats(xnestUpstreamInfo.setup);
const xcb_format_t *fmtend = fmt + xcb_setup_pixmap_formats_length(xnestUpstreamInfo.setup);
for(; fmt != fmtend; ++fmt) {
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 == depth_iter.data->depth) {
if (fmt->depth == 1 || fmt->depth == depth_iter.data->depth) {
uint32_t pixmap = xcb_generate_id(xnestUpstreamInfo.conn);
xcb_create_pixmap(xnestUpstreamInfo.conn,
xnestPixmapFormats[i].depth,
fmt->depth,
pixmap,
xnestUpstreamInfo.screenInfo->root,
1, 1);
xnestDefaultDrawables[xnestPixmapFormats[i].depth] = pixmap;
xnestDefaultDrawables[fmt->depth] = pixmap;
}
}
}
@ -210,6 +207,5 @@ xnestCloseDisplay(void)
free(xnestDefaultColormaps);
XFree(xnestVisuals);
XFree(xnestPixmapFormats);
XCloseDisplay(xnestDisplay);
}

View File

@ -28,7 +28,6 @@ extern int xnestNumVisuals;
extern int xnestDefaultVisualIndex;
extern Colormap *xnestDefaultColormaps;
extern int xnestNumDefaultClormaps;
extern XPixmapFormatValues *xnestPixmapFormats;
extern int xnestNumPixmapFormats;
extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
extern Pixmap xnestIconBitmap;

View File

@ -77,20 +77,23 @@ 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++) {
xcb_format_t *fmt = xcb_setup_pixmap_formats(xnestUpstreamInfo.setup);
const xcb_format_t *fmtend = fmt + xcb_setup_pixmap_formats_length(xnestUpstreamInfo.setup);
for(; fmt != fmtend; ++fmt) {
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 == depth_iter.data->depth)) {
if ((fmt->depth == 1) ||
(fmt->depth == depth_iter.data->depth)) {
screen_info->formats[screen_info->numPixmapFormats].depth =
xnestPixmapFormats[i].depth;
fmt->depth;
screen_info->formats[screen_info->numPixmapFormats].bitsPerPixel =
xnestPixmapFormats[i].bits_per_pixel;
fmt->bits_per_pixel;
screen_info->formats[screen_info->numPixmapFormats].scanlinePad =
xnestPixmapFormats[i].scanline_pad;
fmt->scanline_pad;
screen_info->numPixmapFormats++;
break;
}