105b261ecSmrg/*
205b261ecSmrg
305b261ecSmrgCopyright 1993 by Davor Matic
405b261ecSmrg
505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software
605b261ecSmrgand its documentation for any purpose is hereby granted without fee,
705b261ecSmrgprovided that the above copyright notice appear in all copies and that
805b261ecSmrgboth that copyright notice and this permission notice appear in
905b261ecSmrgsupporting documentation.  Davor Matic makes no representations about
1005b261ecSmrgthe suitability of this software for any purpose.  It is provided "as
1105b261ecSmrgis" without express or implied warranty.
1205b261ecSmrg
1305b261ecSmrg*/
1405b261ecSmrg
1505b261ecSmrg#ifdef HAVE_XNEST_CONFIG_H
1605b261ecSmrg#include <xnest-config.h>
1705b261ecSmrg#endif
1805b261ecSmrg
1905b261ecSmrg#include <X11/X.h>
2005b261ecSmrg#include <X11/Xproto.h>
2105b261ecSmrg#include "scrnintstr.h"
2205b261ecSmrg#include "dix.h"
2305b261ecSmrg#include "mi.h"
2405b261ecSmrg#include "Xnest.h"
2505b261ecSmrg
2605b261ecSmrg#include "Display.h"
2705b261ecSmrg#include "Visual.h"
2805b261ecSmrg
2905b261ecSmrgVisual *
3005b261ecSmrgxnestVisual(VisualPtr pVisual)
3105b261ecSmrg{
3235c4bbdfSmrg    int i;
3305b261ecSmrg
3435c4bbdfSmrg    for (i = 0; i < xnestNumVisuals; i++)
3535c4bbdfSmrg        if (pVisual->class == xnestVisuals[i].class &&
3635c4bbdfSmrg            pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb &&
3735c4bbdfSmrg            pVisual->ColormapEntries == xnestVisuals[i].colormap_size &&
3835c4bbdfSmrg            pVisual->nplanes == xnestVisuals[i].depth &&
3935c4bbdfSmrg            pVisual->redMask == xnestVisuals[i].red_mask &&
4035c4bbdfSmrg            pVisual->greenMask == xnestVisuals[i].green_mask &&
4135c4bbdfSmrg            pVisual->blueMask == xnestVisuals[i].blue_mask)
4235c4bbdfSmrg            return xnestVisuals[i].visual;
4305b261ecSmrg
4435c4bbdfSmrg    return NULL;
4505b261ecSmrg}
4605b261ecSmrg
4705b261ecSmrgVisual *
4805b261ecSmrgxnestVisualFromID(ScreenPtr pScreen, VisualID visual)
4905b261ecSmrg{
5035c4bbdfSmrg    int i;
5105b261ecSmrg
5235c4bbdfSmrg    for (i = 0; i < pScreen->numVisuals; i++)
5335c4bbdfSmrg        if (pScreen->visuals[i].vid == visual)
5435c4bbdfSmrg            return xnestVisual(&pScreen->visuals[i]);
5535c4bbdfSmrg
5635c4bbdfSmrg    return NULL;
5705b261ecSmrg}
5805b261ecSmrg
5905b261ecSmrgColormap
6035c4bbdfSmrgxnestDefaultVisualColormap(Visual * visual)
6105b261ecSmrg{
6235c4bbdfSmrg    int i;
6335c4bbdfSmrg
6435c4bbdfSmrg    for (i = 0; i < xnestNumVisuals; i++)
6535c4bbdfSmrg        if (xnestVisuals[i].visual == visual)
6635c4bbdfSmrg            return xnestDefaultColormaps[i];
6735c4bbdfSmrg
6835c4bbdfSmrg    return None;
6905b261ecSmrg}
70