1706f2543Smrg/*
2706f2543Smrg
3706f2543SmrgCopyright 1993 by Davor Matic
4706f2543Smrg
5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software
6706f2543Smrgand its documentation for any purpose is hereby granted without fee,
7706f2543Smrgprovided that the above copyright notice appear in all copies and that
8706f2543Smrgboth that copyright notice and this permission notice appear in
9706f2543Smrgsupporting documentation.  Davor Matic makes no representations about
10706f2543Smrgthe suitability of this software for any purpose.  It is provided "as
11706f2543Smrgis" without express or implied warranty.
12706f2543Smrg
13706f2543Smrg*/
14706f2543Smrg
15706f2543Smrg#ifdef HAVE_XNEST_CONFIG_H
16706f2543Smrg#include <xnest-config.h>
17706f2543Smrg#endif
18706f2543Smrg
19706f2543Smrg#include <X11/X.h>
20706f2543Smrg#include <X11/Xproto.h>
21706f2543Smrg#include "scrnintstr.h"
22706f2543Smrg#include "dix.h"
23706f2543Smrg#include "mi.h"
24706f2543Smrg#include "mibstore.h"
25706f2543Smrg#include "Xnest.h"
26706f2543Smrg
27706f2543Smrg#include "Display.h"
28706f2543Smrg#include "Visual.h"
29706f2543Smrg
30706f2543SmrgVisual *
31706f2543SmrgxnestVisual(VisualPtr pVisual)
32706f2543Smrg{
33706f2543Smrg  int i;
34706f2543Smrg
35706f2543Smrg  for (i = 0; i < xnestNumVisuals; i++)
36706f2543Smrg    if (pVisual->class == xnestVisuals[i].class &&
37706f2543Smrg	pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb &&
38706f2543Smrg	pVisual->ColormapEntries == xnestVisuals[i].colormap_size &&
39706f2543Smrg	pVisual->nplanes == xnestVisuals[i].depth &&
40706f2543Smrg	pVisual->redMask == xnestVisuals[i].red_mask &&
41706f2543Smrg	pVisual->greenMask == xnestVisuals[i].green_mask &&
42706f2543Smrg	pVisual->blueMask == xnestVisuals[i].blue_mask)
43706f2543Smrg      return xnestVisuals[i].visual;
44706f2543Smrg
45706f2543Smrg  return NULL;
46706f2543Smrg}
47706f2543Smrg
48706f2543SmrgVisual *
49706f2543SmrgxnestVisualFromID(ScreenPtr pScreen, VisualID visual)
50706f2543Smrg{
51706f2543Smrg  int i;
52706f2543Smrg
53706f2543Smrg  for (i = 0; i < pScreen->numVisuals; i++)
54706f2543Smrg    if (pScreen->visuals[i].vid == visual)
55706f2543Smrg      return xnestVisual(&pScreen->visuals[i]);
56706f2543Smrg
57706f2543Smrg  return NULL;
58706f2543Smrg}
59706f2543Smrg
60706f2543SmrgColormap
61706f2543SmrgxnestDefaultVisualColormap(Visual *visual)
62706f2543Smrg{
63706f2543Smrg  int i;
64706f2543Smrg
65706f2543Smrg  for (i = 0; i < xnestNumVisuals; i++)
66706f2543Smrg    if (xnestVisuals[i].visual == visual)
67706f2543Smrg      return xnestDefaultColormaps[i];
68706f2543Smrg
69706f2543Smrg  return None;
70706f2543Smrg}
71