diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c index 3b824b591..6da0a315e 100644 --- a/hw/xnest/Color.c +++ b/hw/xnest/Color.c @@ -26,13 +26,11 @@ is" without express or implied warranty. #include "colormapst.h" #include "resource.h" -#include "Xnest.h" #include "xnest-xcb.h" #include "Display.h" #include "Screen.h" #include "Color.h" -#include "Visual.h" #include "XNWindow.h" #include "Args.h" @@ -98,7 +96,7 @@ xnestCreateColormap(ColormapPtr pCmap) (pVisual->class & DynamicClass) ? XCB_COLORMAP_ALLOC_ALL : XCB_COLORMAP_ALLOC_NONE, cmap, xnestDefaultWindows[pCmap->pScreen->myNum], - xnestVisual(pVisual)->visualid); + xnest_visual_map_to_host(pVisual->vid)); switch (pVisual->class) { case StaticGray: /* read only */ @@ -250,13 +248,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen) */ if (icws.numWindows) { WindowPtr pWin; - Visual *visual; ColormapPtr pCmap; pWin = xnestWindowPtr(icws.windows[0]); - visual = xnestVisualFromID(pScreen, wVisual(pWin)); - if (visual == xnestDefaultVisual(pScreen)) + if (xnest_visual_map_to_host(wVisual(pWin)) == + xnest_visual_map_to_host(pScreen->rootVisual)) dixLookupResourceByType((void **) &pCmap, wColormap(pWin), X11_RESTYPE_COLORMAP, serverClient, DixUseAccess); diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 0e1dbd3ff..f1c884b29 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -34,7 +34,6 @@ is" without express or implied warranty. #include "Display.h" #include "Screen.h" #include "XNCursor.h" -#include "Visual.h" #include "Keyboard.h" #include "Args.h" diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 815981aa7..a66526dfc 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -38,7 +38,6 @@ is" without express or implied warranty. #include "XNFont.h" #include "GCOps.h" #include "Drawable.h" -#include "Visual.h" void xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint * pPoints, diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 31460b05c..ca22ac1a3 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -42,7 +42,6 @@ is" without express or implied warranty. #include "XNFont.h" #include "Color.h" #include "XNCursor.h" -#include "Visual.h" #include "Events.h" #include "Init.h" #include "mipointer.h" @@ -411,7 +410,7 @@ breakout: XnSetWindowAttr attributes = { .background_pixel = xnestUpstreamInfo.screenInfo->white_pixel, .event_mask = xnestEventMask, - .colormap = xnestDefaultVisualColormap(xnestDefaultVisual(pScreen)), + .colormap = xnestVisualToHostCmap(pScreen->rootVisual), }; valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP; @@ -438,7 +437,7 @@ breakout: xnestGeometry.height, xnestBorderWidth, XCB_WINDOW_CLASS_INPUT_OUTPUT, - xnestDefaultVisual(pScreen)->visualid, + xnest_visual_map_to_host(pScreen->rootVisual), valuemask, values); } diff --git a/hw/xnest/Visual.h b/hw/xnest/Visual.h index 12f19d9ab..3438849e0 100644 --- a/hw/xnest/Visual.h +++ b/hw/xnest/Visual.h @@ -21,7 +21,6 @@ Visual *xnestVisual(VisualPtr pVisual); Visual *xnestVisualFromID(ScreenPtr pScreen, VisualID visual); Colormap xnestDefaultVisualColormap(Visual * visual); -#define xnestDefaultVisual(pScreen) \ - xnestVisualFromID((pScreen), (pScreen)->rootVisual) +VisualPtr ScreenGetVisual(ScreenPtr pScreen, VisualID visual); #endif /* XNESTVISUAL_H */ diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 0bd32ecea..2aea90efc 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -41,7 +41,6 @@ is" without express or implied warranty. #include "XNGC.h" #include "Drawable.h" #include "Color.h" -#include "Visual.h" #include "Events.h" #include "Args.h" @@ -83,7 +82,7 @@ xnestCreateWindow(WindowPtr pWin) { unsigned long mask; XnSetWindowAttr attributes = { 0 }; - Visual *visual; + uint32_t visual = CopyFromParent; /* 0L */ ColormapPtr pCmap; uint32_t params[32] = { 0 }; @@ -99,8 +98,7 @@ xnestCreateWindow(WindowPtr pWin) if (pWin->parent) { if (pWin->optional && pWin->optional->visual != wVisual(pWin->parent)) { - visual = - xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); + visual = xnest_visual_map_to_host(wVisual(pWin)); mask |= XCB_CW_COLORMAP; if (pWin->optional->colormap) { dixLookupResourceByType((void **) &pCmap, wColormap(pWin), @@ -109,13 +107,13 @@ xnestCreateWindow(WindowPtr pWin) attributes.colormap = xnestColormap(pCmap); } else - attributes.colormap = xnestDefaultVisualColormap(visual); + attributes.colormap = xnestHostVisualToHostCmap(visual); } else visual = CopyFromParent; } else { /* root windows have their own colormaps at creation time */ - visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin)); + visual = xnest_visual_map_to_host(wVisual(pWin)); dixLookupResourceByType((void **) &pCmap, wColormap(pWin), X11_RESTYPE_COLORMAP, serverClient, DixUseAccess); mask |= XCB_CW_COLORMAP; @@ -135,7 +133,7 @@ xnestCreateWindow(WindowPtr pWin) pWin->drawable.height, pWin->borderWidth, pWin->drawable.class, - (visual ? visual->visualid : 0), + visual, mask, ¶ms); diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index e56132d91..ce978d803 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -19,7 +19,6 @@ #include "xnest-xcb.h" #include "xnest-xkb.h" #include "XNGC.h" - #include "Display.h" xnestUpstreamInfoRec xnestUpstreamInfo = { 0 }; @@ -517,3 +516,33 @@ int xnestParseGeometry(const char *string, xRectangle *geometry) return mask; } + +uint32_t xnest_visual_map_to_host(VisualID visual) +{ + for (int i = 0; i < xnestNumVisualMap; i++) { + if (xnestVisualMap[i].ourXID == visual) { + return xnestVisualMap[i].upstreamVisual->visual_id; + } + } + return XCB_NONE; +} + +uint32_t xnestHostVisualToHostCmap(uint32_t upstreamVisual) +{ + for (int i = 0; i < xnestNumVisualMap; i++) { + if (xnestVisualMap[i].upstreamVisual->visual_id == upstreamVisual) { + return xnestVisualMap[i].upstreamCMap; + } + } + return XCB_COLORMAP_NONE; +} + +uint32_t xnestVisualToHostCmap(uint32_t visual) +{ + for (int i = 0; i < xnestNumVisualMap; i++) { + if (xnestVisualMap[i].ourXID == visual) { + return xnestVisualMap[i].upstreamCMap; + } + } + return XCB_COLORMAP_NONE; +} diff --git a/hw/xnest/xnest-xcb.h b/hw/xnest/xnest-xcb.h index 9611f25f7..c153b921a 100644 --- a/hw/xnest/xnest-xcb.h +++ b/hw/xnest/xnest-xcb.h @@ -132,4 +132,8 @@ xRectangle xnestGetGeometry(xcb_connection_t *conn, uint32_t window); int xnestParseGeometry(const char *string, xRectangle *geometry); +uint32_t xnest_visual_map_to_host(VisualID visual); +uint32_t xnestHostVisualToHostCmap(uint32_t visual); +uint32_t xnestVisualToHostCmap(uint32_t visual); + #endif /* __XNEST__XCB_H */