Xnest: replace XCreateColormap() / XFreeColormap() by xcb

Use xcb_create_colormap() and XFreeColormap() instead of XCreateColormap()
and XFreeColormap().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-31 20:48:17 +02:00
parent edd0d03e0b
commit 911ef9c365
2 changed files with 19 additions and 12 deletions

View File

@ -25,6 +25,7 @@ is" without express or implied warranty.
#include "resource.h" #include "resource.h"
#include "Xnest.h" #include "Xnest.h"
#include "xnest-xcb.h"
#include "Display.h" #include "Display.h"
#include "Screen.h" #include "Screen.h"
@ -54,11 +55,14 @@ xnestCreateColormap(ColormapPtr pCmap)
pVisual = pCmap->pVisual; pVisual = pCmap->pVisual;
ncolors = pVisual->ColormapEntries; ncolors = pVisual->ColormapEntries;
xnestColormapPriv(pCmap)->colormap = uint32_t const cmap = xcb_generate_id(xnestUpstreamInfo.conn);
XCreateColormap(xnestDisplay, xnestColormapPriv(pCmap)->colormap = cmap;
xcb_create_colormap(xnestUpstreamInfo.conn,
(pVisual->class & DynamicClass) ? XCB_COLORMAP_ALLOC_ALL : XCB_COLORMAP_ALLOC_NONE,
cmap,
xnestDefaultWindows[pCmap->pScreen->myNum], xnestDefaultWindows[pCmap->pScreen->myNum],
xnestVisual(pVisual), xnestVisual(pVisual)->visualid);
(pVisual->class & DynamicClass) ? AllocAll : AllocNone);
switch (pVisual->class) { switch (pVisual->class) {
case StaticGray: /* read only */ case StaticGray: /* read only */
@ -133,7 +137,7 @@ xnestCreateColormap(ColormapPtr pCmap)
void void
xnestDestroyColormap(ColormapPtr pCmap) xnestDestroyColormap(ColormapPtr pCmap)
{ {
XFreeColormap(xnestDisplay, xnestColormap(pCmap)); xcb_free_colormap(xnestUpstreamInfo.conn, xnestColormap(pCmap));
} }
#define SEARCH_PREDICATE \ #define SEARCH_PREDICATE \

View File

@ -117,13 +117,16 @@ xnestOpenDisplay(int argc, char *argv[])
} }
xnestNumDefaultColormaps = xnestNumVisuals; xnestNumDefaultColormaps = xnestNumVisuals;
if (!(xnestDefaultColormaps = calloc(xnestNumDefaultColormaps, sizeof(Colormap)))) xnestDefaultColormaps = calloc(xnestNumDefaultColormaps,
return; sizeof(Colormap));
for (i = 0; i < xnestNumDefaultColormaps; i++) for (i = 0; i < xnestNumDefaultColormaps; i++) {
xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay, xnestDefaultColormaps[i] = xcb_generate_id(xnestUpstreamInfo.conn);
xnestUpstreamInfo.screenInfo->root, xcb_create_colormap(xnestUpstreamInfo.conn,
xnestVisuals[i].visual, XCB_COLORMAP_ALLOC_NONE,
AllocNone); xnestDefaultColormaps[i],
xnestUpstreamInfo.screenInfo->root,
xnestVisuals[i].visual->visualid);
}
xnestDepths = XListDepths(xnestDisplay, xnestUpstreamInfo.screenId, xnestDepths = XListDepths(xnestDisplay, xnestUpstreamInfo.screenId,
&xnestNumDepths); &xnestNumDepths);