XGetVisualInfo giving me a visual that doesn't work

Greg Abram gda at tacc.utexas.edu
Tue Feb 1 10:21:57 PST 2011


This looks like an X11 bug to me... this code creates a visual of depth 
32, uses it to create a window, and  blows up under the XMapRaised with 
BadMatch in X_CreateWindow.  xdpyinfo shows that the selected visual is 
correctly a 32 bit TrueColor visual.  If I request a 24 bit visual, its OK.


int
main(int argc, char *argv[])
{
     Display *dpy = XOpenDisplay(":0.0");

     XVisualInfo *vinf, tmp;
     long mask; int n;
     mask = VisualDepthMask | VisualClassMask;
     tmp.depth = 32;
     tmp.c_class = 4;
     vinf = XGetVisualInfo(dpy, mask, &tmp, &n);

     Window win = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 256, 
256, 0,
             vinf->depth, InputOutput, vinf->visual, 0, NULL);

     if (! win)
     {
         std::cerr << "unable to create window\n";
         exit(1);
     }

     XMapRaised(dpy, win);
}


-- 
Gregory D. Abram, Ph.D.
Texas Advanced Computing Center
JJ Pickle Research Campus - ROC 1.101 Bldg 196
10100 Burnet Road
Austin, TX 78758-4497


gda at tacc.utexas.edu
(512) 471-8196




More information about the xorg mailing list