Xnest: use new lookup table for visuals and cmaps mappings
Use the visuals lookup table introduced by previous commit for looking up local vs upstream visuals and their colormaps. Replacing the the old Xlib visuals table. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
6977718454
commit
2956ea0f7d
|
@ -24,13 +24,11 @@ is" without express or implied warranty.
|
||||||
#include "windowstr.h"
|
#include "windowstr.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#include "Xnest.h"
|
|
||||||
#include "xnest-xcb.h"
|
#include "xnest-xcb.h"
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "Visual.h"
|
|
||||||
#include "XNWindow.h"
|
#include "XNWindow.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ xnestCreateColormap(ColormapPtr pCmap)
|
||||||
(pVisual->class & DynamicClass) ? XCB_COLORMAP_ALLOC_ALL : XCB_COLORMAP_ALLOC_NONE,
|
(pVisual->class & DynamicClass) ? XCB_COLORMAP_ALLOC_ALL : XCB_COLORMAP_ALLOC_NONE,
|
||||||
cmap,
|
cmap,
|
||||||
xnestDefaultWindows[pCmap->pScreen->myNum],
|
xnestDefaultWindows[pCmap->pScreen->myNum],
|
||||||
xnestVisual(pVisual)->visualid);
|
xnest_visual_map_to_upstream(pVisual->vid));
|
||||||
|
|
||||||
switch (pVisual->class) {
|
switch (pVisual->class) {
|
||||||
case StaticGray: /* read only */
|
case StaticGray: /* read only */
|
||||||
|
@ -252,13 +250,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
|
||||||
*/
|
*/
|
||||||
if (icws.numWindows) {
|
if (icws.numWindows) {
|
||||||
WindowPtr pWin;
|
WindowPtr pWin;
|
||||||
Visual *visual;
|
|
||||||
ColormapPtr pCmap;
|
ColormapPtr pCmap;
|
||||||
|
|
||||||
pWin = xnestWindowPtr(icws.windows[0]);
|
pWin = xnestWindowPtr(icws.windows[0]);
|
||||||
visual = xnestVisualFromID(pScreen, wVisual(pWin));
|
|
||||||
|
|
||||||
if (visual == xnestDefaultVisual(pScreen))
|
if (xnest_visual_map_to_upstream(wVisual(pWin)) ==
|
||||||
|
xnest_visual_map_to_upstream(pScreen->rootVisual))
|
||||||
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
||||||
X11_RESTYPE_COLORMAP, serverClient,
|
X11_RESTYPE_COLORMAP, serverClient,
|
||||||
DixUseAccess);
|
DixUseAccess);
|
||||||
|
|
|
@ -36,7 +36,6 @@ is" without express or implied warranty.
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "XNCursor.h"
|
#include "XNCursor.h"
|
||||||
#include "Visual.h"
|
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ is" without express or implied warranty.
|
||||||
#include "XNFont.h"
|
#include "XNFont.h"
|
||||||
#include "GCOps.h"
|
#include "GCOps.h"
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
#include "Visual.h"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint * pPoints,
|
xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint * pPoints,
|
||||||
|
|
|
@ -41,7 +41,6 @@ is" without express or implied warranty.
|
||||||
#include "XNFont.h"
|
#include "XNFont.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "XNCursor.h"
|
#include "XNCursor.h"
|
||||||
#include "Visual.h"
|
|
||||||
#include "Events.h"
|
#include "Events.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
#include "mipointer.h"
|
#include "mipointer.h"
|
||||||
|
@ -411,7 +410,7 @@ breakout:
|
||||||
xcb_params_cw_t attributes = {
|
xcb_params_cw_t attributes = {
|
||||||
.back_pixel = xnestUpstreamInfo.screenInfo->white_pixel,
|
.back_pixel = xnestUpstreamInfo.screenInfo->white_pixel,
|
||||||
.event_mask = xnestEventMask,
|
.event_mask = xnestEventMask,
|
||||||
.colormap = xnestDefaultVisualColormap(xnestDefaultVisual(pScreen)),
|
.colormap = xnest_visual_to_upstream_cmap(pScreen->rootVisual),
|
||||||
};
|
};
|
||||||
|
|
||||||
valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
|
valuemask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
|
||||||
|
@ -435,7 +434,7 @@ breakout:
|
||||||
xnestGeometry.height,
|
xnestGeometry.height,
|
||||||
xnestBorderWidth,
|
xnestBorderWidth,
|
||||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||||
xnestDefaultVisual(pScreen)->visualid,
|
xnest_visual_map_to_upstream(pScreen->rootVisual),
|
||||||
valuemask,
|
valuemask,
|
||||||
&attributes);
|
&attributes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright 1993 by Davor Matic
|
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this software
|
|
||||||
and its documentation for any purpose is hereby granted without fee,
|
|
||||||
provided that the above copyright notice appear in all copies and that
|
|
||||||
both that copyright notice and this permission notice appear in
|
|
||||||
supporting documentation. Davor Matic makes no representations about
|
|
||||||
the suitability of this software for any purpose. It is provided "as
|
|
||||||
is" without express or implied warranty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include <dix-config.h>
|
|
||||||
|
|
||||||
#include <X11/X.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include "scrnintstr.h"
|
|
||||||
#include "dix.h"
|
|
||||||
#include "mi.h"
|
|
||||||
#include "Xnest.h"
|
|
||||||
|
|
||||||
#include "Display.h"
|
|
||||||
#include "Visual.h"
|
|
||||||
|
|
||||||
Visual *
|
|
||||||
xnestVisual(VisualPtr pVisual)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < xnestNumVisuals; i++)
|
|
||||||
if (pVisual->class == xnestVisuals[i].class &&
|
|
||||||
pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb &&
|
|
||||||
pVisual->ColormapEntries == xnestVisuals[i].colormap_size &&
|
|
||||||
pVisual->nplanes == xnestVisuals[i].depth &&
|
|
||||||
pVisual->redMask == xnestVisuals[i].red_mask &&
|
|
||||||
pVisual->greenMask == xnestVisuals[i].green_mask &&
|
|
||||||
pVisual->blueMask == xnestVisuals[i].blue_mask)
|
|
||||||
return xnestVisuals[i].visual;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Visual *
|
|
||||||
xnestVisualFromID(ScreenPtr pScreen, VisualID visual)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < pScreen->numVisuals; i++)
|
|
||||||
if (pScreen->visuals[i].vid == visual)
|
|
||||||
return xnestVisual(&pScreen->visuals[i]);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Colormap
|
|
||||||
xnestDefaultVisualColormap(Visual * visual)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < xnestNumVisuals; i++)
|
|
||||||
if (xnestVisuals[i].visual == visual)
|
|
||||||
return xnestDefaultColormaps[i];
|
|
||||||
|
|
||||||
return XCB_WINDOW_NONE;
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright 1993 by Davor Matic
|
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this software
|
|
||||||
and its documentation for any purpose is hereby granted without fee,
|
|
||||||
provided that the above copyright notice appear in all copies and that
|
|
||||||
both that copyright notice and this permission notice appear in
|
|
||||||
supporting documentation. Davor Matic makes no representations about
|
|
||||||
the suitability of this software for any purpose. It is provided "as
|
|
||||||
is" without express or implied warranty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef XNESTVISUAL_H
|
|
||||||
#define XNESTVISUAL_H
|
|
||||||
|
|
||||||
#include <X11/X.h>
|
|
||||||
|
|
||||||
Visual *xnestVisual(VisualPtr pVisual);
|
|
||||||
Visual *xnestVisualFromID(ScreenPtr pScreen, VisualID visual);
|
|
||||||
Colormap xnestDefaultVisualColormap(Visual * visual);
|
|
||||||
|
|
||||||
#define xnestDefaultVisual(pScreen) \
|
|
||||||
xnestVisualFromID((pScreen), (pScreen)->rootVisual)
|
|
||||||
|
|
||||||
#endif /* XNESTVISUAL_H */
|
|
|
@ -38,7 +38,6 @@ is" without express or implied warranty.
|
||||||
#include "XNGC.h"
|
#include "XNGC.h"
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "Visual.h"
|
|
||||||
#include "Events.h"
|
#include "Events.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ xnestCreateWindow(WindowPtr pWin)
|
||||||
{
|
{
|
||||||
unsigned long mask;
|
unsigned long mask;
|
||||||
xcb_params_cw_t attributes = { 0 };
|
xcb_params_cw_t attributes = { 0 };
|
||||||
Visual *visual;
|
uint32_t visual = CopyFromParent; /* 0L */
|
||||||
ColormapPtr pCmap;
|
ColormapPtr pCmap;
|
||||||
|
|
||||||
if (pWin->drawable.class == InputOnly) {
|
if (pWin->drawable.class == InputOnly) {
|
||||||
|
@ -95,8 +94,7 @@ xnestCreateWindow(WindowPtr pWin)
|
||||||
if (pWin->parent) {
|
if (pWin->parent) {
|
||||||
if (pWin->optional &&
|
if (pWin->optional &&
|
||||||
pWin->optional->visual != wVisual(pWin->parent)) {
|
pWin->optional->visual != wVisual(pWin->parent)) {
|
||||||
visual =
|
visual = xnest_visual_map_to_upstream(wVisual(pWin));
|
||||||
xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
|
|
||||||
mask |= XCB_CW_COLORMAP;
|
mask |= XCB_CW_COLORMAP;
|
||||||
if (pWin->optional->colormap) {
|
if (pWin->optional->colormap) {
|
||||||
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
||||||
|
@ -105,13 +103,13 @@ xnestCreateWindow(WindowPtr pWin)
|
||||||
attributes.colormap = xnestColormap(pCmap);
|
attributes.colormap = xnestColormap(pCmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
attributes.colormap = xnestDefaultVisualColormap(visual);
|
attributes.colormap = xnest_upstream_visual_to_cmap(visual);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
visual = CopyFromParent;
|
visual = CopyFromParent;
|
||||||
}
|
}
|
||||||
else { /* root windows have their own colormaps at creation time */
|
else { /* root windows have their own colormaps at creation time */
|
||||||
visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
|
visual = xnest_visual_map_to_upstream(wVisual(pWin));
|
||||||
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
dixLookupResourceByType((void **) &pCmap, wColormap(pWin),
|
||||||
X11_RESTYPE_COLORMAP, serverClient, DixUseAccess);
|
X11_RESTYPE_COLORMAP, serverClient, DixUseAccess);
|
||||||
mask |= XCB_CW_COLORMAP;
|
mask |= XCB_CW_COLORMAP;
|
||||||
|
@ -130,7 +128,7 @@ xnestCreateWindow(WindowPtr pWin)
|
||||||
pWin->drawable.height,
|
pWin->drawable.height,
|
||||||
pWin->borderWidth,
|
pWin->borderWidth,
|
||||||
pWin->drawable.class,
|
pWin->drawable.class,
|
||||||
(visual ? visual->visualid : 0),
|
visual,
|
||||||
mask,
|
mask,
|
||||||
&attributes);
|
&attributes);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ srcs = [
|
||||||
'Pixmap.c',
|
'Pixmap.c',
|
||||||
'Pointer.c',
|
'Pointer.c',
|
||||||
'Screen.c',
|
'Screen.c',
|
||||||
'Visual.c',
|
|
||||||
'Window.c',
|
'Window.c',
|
||||||
'../../mi/miinitext.c',
|
'../../mi/miinitext.c',
|
||||||
'../../mi/miinitext.h',
|
'../../mi/miinitext.h',
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "xnest-xcb.h"
|
#include "xnest-xcb.h"
|
||||||
#include "xnest-xkb.h"
|
#include "xnest-xkb.h"
|
||||||
#include "XNGC.h"
|
#include "XNGC.h"
|
||||||
|
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
|
||||||
struct xnest_upstream_info xnestUpstreamInfo = { 0 };
|
struct xnest_upstream_info xnestUpstreamInfo = { 0 };
|
||||||
|
@ -417,3 +416,33 @@ int xnest_parse_geometry(const char *string, xRectangle *geometry)
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t xnest_visual_map_to_upstream(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 xnest_upstream_visual_to_cmap(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 xnest_visual_to_upstream_cmap(uint32_t visual)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < xnestNumVisualMap; i++) {
|
||||||
|
if (xnestVisualMap[i].ourXID == visual) {
|
||||||
|
return xnestVisualMap[i].upstreamCMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return XCB_COLORMAP_NONE;
|
||||||
|
}
|
||||||
|
|
|
@ -58,4 +58,8 @@ xRectangle xnest_get_geometry(xcb_connection_t *conn, uint32_t window);
|
||||||
|
|
||||||
int xnest_parse_geometry(const char *string, xRectangle *geometry);
|
int xnest_parse_geometry(const char *string, xRectangle *geometry);
|
||||||
|
|
||||||
|
uint32_t xnest_visual_map_to_upstream(VisualID visual);
|
||||||
|
uint32_t xnest_upstream_visual_to_cmap(uint32_t visual);
|
||||||
|
uint32_t xnest_visual_to_upstream_cmap(uint32_t visual);
|
||||||
|
|
||||||
#endif /* __XNEST__XCB_H */
|
#endif /* __XNEST__XCB_H */
|
||||||
|
|
Loading…
Reference in New Issue