error creating non default depth window - Motif

This is a discussion on error creating non default depth window - Motif ; hello, Can someone please tell me what I doing wrong?. I am trying to build a 8 bit window on a machine whose default is 24 bit. This is my code: #include #include #include #include #include #include Widget toplevel, main_w; ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: error creating non default depth window

  1. error creating non default depth window

    hello,


    Can someone please tell me what I doing wrong?. I am trying to build a
    8 bit window on a machine whose default is 24 bit.

    This is my code:

    #include
    #include
    #include
    #include
    #include
    #include

    Widget toplevel, main_w;
    Visual* visual;
    Colormap colorMap;
    unsigned int depth;
    Pixmap pixmap;


    int main(int argc, char* argv[])
    {
    XtAppContext app;
    Colormap cmap;
    Display *dpy;
    Window win, win1;
    XVisualInfo vTemplate;
    XVisualInfo *visualList;
    int visualsMatched;
    XSetWindowAttributes attrbs;
    unsigned long valueMask;

    dpy = XOpenDisplay(NULL);

    win = DefaultRootWindow(dpy);

    /*
    * Obtain a list of TrueColor visuals with 24 bit depth
    */
    visualList = NULL;
    vTemplate.screen = DefaultScreen(dpy);
    vTemplate.class = PseudoColor;
    vTemplate.depth = 8;
    visualList = XGetVisualInfo(dpy,
    VisualDepthMask | VisualScreenMask |
    VisualClassMask,
    &vTemplate, &visualsMatched);


    /*if (visualsMatched == 0)
    {


    if (visualList == NULL)


    }*/

    visual = visualList[0].visual;
    depth = visualList[0].depth;
    printf("depth is: %d\n", depth);

    colorMap = XCreateColormap(dpy,win,visual,AllocNone);

    attrbs.colormap = colorMap;
    valueMask = CWColormap;


    XsetWindowColormap(dpy, win, colorMap);
    XFlush(dpy);

    XFree(visualList);


    toplevel= XtVaAppInitialize(&app, "myapp", NULL, 0,
    &argc, argv, NULL, XmNvisual, visual,
    XmNdepth, 8, XmNcolormap, colorMap,XmNwidth, 600,
    XmNheight, 600, XmNpixmap, pixmap,NULL);


    /*When the line below is uncommented and the creation of main_w
    is commented, I have no errors*/
    /*win1 = XCreateWindow(dpy, win, 100,100,600,600,5,8,InputOutput,
    visual, valueMask, &attrbs);*/

    main_w=XtVaCreateManagedWidget("main
    window",xmMainWindowWidgetClass, toplevel, XmNvisual, visual,
    XmNdepth, depth, XmNcolormap, colorMap, XmNpixmap,
    pixmap, NULL);



    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);
    }


    The above code gives me an error:
    X Error of failed request: BadValue (integer parameter out of range
    for operati
    on)
    Major opcode of failed request: 91 (X_QueryColors)
    Value in failed request: 0x999999
    Serial number of failed request: 64
    Current serial number in output stream: 64


    As you can see i have created matching colormap, viual and depth.
    However if I try to create a window using xcreate then I have no
    errors in creatong a 8 bit window. What am I doing wrong when I use
    the Xt function to create a widget.

    --vijay

  2. Re: error creating non default depth window

    vijay wrote:

    > hello,
    >
    >
    > Can someone please tell me what I doing wrong?. I am trying to build a
    > 8 bit window on a machine whose default is 24 bit.
    >
    > This is my code:
    >
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    >
    > Widget toplevel, main_w;
    > Visual* visual;
    > Colormap colorMap;
    > unsigned int depth;
    > Pixmap pixmap;
    >
    >
    > int main(int argc, char* argv[])
    > {
    > XtAppContext app;
    > Colormap cmap;
    > Display *dpy;
    > Window win, win1;
    > XVisualInfo vTemplate;
    > XVisualInfo *visualList;
    > int visualsMatched;
    > XSetWindowAttributes attrbs;
    > unsigned long valueMask;
    >
    > dpy = XOpenDisplay(NULL);
    >
    > win = DefaultRootWindow(dpy);
    >
    > /*
    > * Obtain a list of TrueColor visuals with 24 bit depth
    > */


    Having *false* comments is worse than having none at all...

    > visualList = NULL;
    > vTemplate.screen = DefaultScreen(dpy);
    > vTemplate.class = PseudoColor;
    > vTemplate.depth = 8;
    > visualList = XGetVisualInfo(dpy,
    > VisualDepthMask | VisualScreenMask |
    > VisualClassMask,
    > &vTemplate, &visualsMatched);
    >
    >
    > /*if (visualsMatched == 0)
    > {
    >
    >
    > if (visualList == NULL)
    >
    >
    > }*/
    >
    > visual = visualList[0].visual;
    > depth = visualList[0].depth;
    > printf("depth is: %d\n", depth);
    >
    > colorMap = XCreateColormap(dpy,win,visual,AllocNone);
    >
    > attrbs.colormap = colorMap;
    > valueMask = CWColormap;
    >
    >
    > XsetWindowColormap(dpy, win, colorMap);
    > XFlush(dpy);
    >
    > XFree(visualList);
    >
    >
    > toplevel= XtVaAppInitialize(&app, "myapp", NULL, 0,
    > &argc, argv, NULL, XmNvisual, visual,
    > XmNdepth, 8, XmNcolormap, colorMap,XmNwidth, 600,
    > XmNheight, 600, XmNpixmap, pixmap,NULL);
    >
    >
    > /*When the line below is uncommented and the creation of main_w
    > is commented, I have no errors*/
    > /*win1 = XCreateWindow(dpy, win, 100,100,600,600,5,8,InputOutput,
    > visual, valueMask, &attrbs);*/
    >
    > main_w=XtVaCreateManagedWidget("main
    > window",xmMainWindowWidgetClass, toplevel, XmNvisual, visual,
    > XmNdepth, depth, XmNcolormap, colorMap, XmNpixmap,
    > pixmap, NULL);
    >
    >
    >
    > XtRealizeWidget(toplevel);
    > XtAppMainLoop(app);
    > }
    >
    >
    > The above code gives me an error:
    > X Error of failed request: BadValue (integer parameter out of range
    > for operati
    > on)
    > Major opcode of failed request: 91 (X_QueryColors)
    > Value in failed request: 0x999999
    > Serial number of failed request: 64
    > Current serial number in output stream: 64
    >
    >
    > As you can see i have created matching colormap, viual and depth.
    > However if I try to create a window using xcreate then I have no
    > errors in creatong a 8 bit window. What am I doing wrong when I use
    > the Xt function to create a widget.
    >
    > --vijay


    I have just tried this code on:

    Client: debian woody with openmotif_2.1.30-5_i386.deb

    Server: from xdpyinfo:

    name of display: gnocchi:0.0
    version number: 11.0
    vendor string: Hummingbird Ltd.
    vendor release number: 8000
    maximum request size: 4194300 bytes
    motion buffer size: 1
    bitmap unit, bit order, padding: 8, MSBFirst, 32
    image byte order: MSBFirst
    number of supported pixmap formats: 4
    supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 12, bits_per_pixel 12, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    keycode range: minimum 8, maximum 254
    focus: window 0x800005, revert to PointerRoot
    number of extensions: 13
    BIG-REQUESTS
    DOUBLE-BUFFER
    Extended-Visual-Information
    HCL-DOS-Access
    HCLMISC
    HCLxperf
    LBX
    SECURITY
    SHAPE
    TOG-CUP
    XC-APPGROUP
    XC-MISC
    XInputExtension
    default screen number: 0
    number of screens: 1

    screen #0:
    dimensions: 1280x1024 pixels (320x240 millimeters)
    resolution: 102x108 dots per inch
    depths (4): 1, 8, 12, 24
    root window id: 0x34
    depth of root window: 24 planes
    number of colormaps: minimum 8183, maximum 8183
    default colormap: 0x20
    default number of colormap cells: 256
    preallocated pixels: black 0, white 16777215
    options: backing-store WHEN MAPPED, save-unders NO
    largest cursor: 32x32
    current input event mask: 0x780000
    SubstructureNotifyMask SubstructureRedirectMask FocusChangeMask

    PropertyChangeMask
    number of visuals: 3
    default visual id: 0x23
    visual:
    visual id: 0x21
    class: PseudoColor
    depth: 8 planes
    available colormap entries: 256
    red, green, blue masks: 0x0, 0x0, 0x0
    significant bits in color specification: 8 bits
    visual:
    visual id: 0x22
    class: PseudoColor
    depth: 12 planes
    available colormap entries: 4096
    red, green, blue masks: 0x0, 0x0, 0x0
    significant bits in color specification: 8 bits
    visual:
    visual id: 0x23
    class: TrueColor
    depth: 24 planes
    available colormap entries: 256 per subfield
    red, green, blue masks: 0xff, 0xff00, 0xff0000
    significant bits in color specification: 8 bits

    and I have no error. Since your problem seems platform-specific, please
    post info on client and server.


    --
    Michel Bardiaux
    Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
    Tel : +32 2 790.29.41


  3. Re: error creating non default depth window

    Michel Bardiaux wrote in message news:...
    > vijay wrote:
    >
    > > hello,
    > >
    > >
    > > Can someone please tell me what I doing wrong?. I am trying to build a
    > > 8 bit window on a machine whose default is 24 bit.
    > >
    > > This is my code:
    > >
    > > #include
    > > #include
    > > #include
    > > #include
    > > #include
    > > #include
    > >
    > > Widget toplevel, main_w;
    > > Visual* visual;
    > > Colormap colorMap;
    > > unsigned int depth;
    > > Pixmap pixmap;
    > >
    > >
    > > int main(int argc, char* argv[])
    > > {
    > > XtAppContext app;
    > > Colormap cmap;
    > > Display *dpy;
    > > Window win, win1;
    > > XVisualInfo vTemplate;
    > > XVisualInfo *visualList;
    > > int visualsMatched;
    > > XSetWindowAttributes attrbs;
    > > unsigned long valueMask;
    > >
    > > dpy = XOpenDisplay(NULL);
    > >
    > > win = DefaultRootWindow(dpy);
    > >
    > > /*
    > > * Obtain a list of TrueColor visuals with 24 bit depth
    > > */

    >
    > Having *false* comments is worse than having none at all...
    >
    > > visualList = NULL;
    > > vTemplate.screen = DefaultScreen(dpy);
    > > vTemplate.class = PseudoColor;
    > > vTemplate.depth = 8;
    > > visualList = XGetVisualInfo(dpy,
    > > VisualDepthMask | VisualScreenMask |
    > > VisualClassMask,
    > > &vTemplate, &visualsMatched);
    > >
    > >
    > > /*if (visualsMatched == 0)
    > > {
    > >
    > >
    > > if (visualList == NULL)
    > >
    > >
    > > }*/
    > >
    > > visual = visualList[0].visual;
    > > depth = visualList[0].depth;
    > > printf("depth is: %d\n", depth);
    > >
    > > colorMap = XCreateColormap(dpy,win,visual,AllocNone);
    > >
    > > attrbs.colormap = colorMap;
    > > valueMask = CWColormap;
    > >
    > >
    > > XsetWindowColormap(dpy, win, colorMap);
    > > XFlush(dpy);
    > >
    > > XFree(visualList);
    > >
    > >
    > > toplevel= XtVaAppInitialize(&app, "myapp", NULL, 0,
    > > &argc, argv, NULL, XmNvisual, visual,
    > > XmNdepth, 8, XmNcolormap, colorMap,XmNwidth, 600,
    > > XmNheight, 600, XmNpixmap, pixmap,NULL);
    > >
    > >
    > > /*When the line below is uncommented and the creation of main_w
    > > is commented, I have no errors*/
    > > /*win1 = XCreateWindow(dpy, win, 100,100,600,600,5,8,InputOutput,
    > > visual, valueMask, &attrbs);*/
    > >
    > > main_w=XtVaCreateManagedWidget("main
    > > window",xmMainWindowWidgetClass, toplevel, XmNvisual, visual,
    > > XmNdepth, depth, XmNcolormap, colorMap, XmNpixmap,
    > > pixmap, NULL);
    > >
    > >
    > >
    > > XtRealizeWidget(toplevel);
    > > XtAppMainLoop(app);
    > > }
    > >
    > >
    > > The above code gives me an error:
    > > X Error of failed request: BadValue (integer parameter out of range
    > > for operati
    > > on)
    > > Major opcode of failed request: 91 (X_QueryColors)
    > > Value in failed request: 0x999999
    > > Serial number of failed request: 64
    > > Current serial number in output stream: 64
    > >
    > >
    > > As you can see i have created matching colormap, viual and depth.
    > > However if I try to create a window using xcreate then I have no
    > > errors in creatong a 8 bit window. What am I doing wrong when I use
    > > the Xt function to create a widget.
    > >
    > > --vijay

    >
    > I have just tried this code on:
    >
    > Client: debian woody with openmotif_2.1.30-5_i386.deb
    >
    > Server: from xdpyinfo:
    >
    > name of display: gnocchi:0.0
    > version number: 11.0
    > vendor string: Hummingbird Ltd.
    > vendor release number: 8000
    > maximum request size: 4194300 bytes
    > motion buffer size: 1
    > bitmap unit, bit order, padding: 8, MSBFirst, 32
    > image byte order: MSBFirst
    > number of supported pixmap formats: 4
    > supported pixmap formats:
    > depth 1, bits_per_pixel 1, scanline_pad 32
    > depth 8, bits_per_pixel 8, scanline_pad 32
    > depth 12, bits_per_pixel 12, scanline_pad 32
    > depth 24, bits_per_pixel 32, scanline_pad 32
    > keycode range: minimum 8, maximum 254
    > focus: window 0x800005, revert to PointerRoot
    > number of extensions: 13
    > BIG-REQUESTS
    > DOUBLE-BUFFER
    > Extended-Visual-Information
    > HCL-DOS-Access
    > HCLMISC
    > HCLxperf
    > LBX
    > SECURITY
    > SHAPE
    > TOG-CUP
    > XC-APPGROUP
    > XC-MISC
    > XInputExtension
    > default screen number: 0
    > number of screens: 1
    >
    > screen #0:
    > dimensions: 1280x1024 pixels (320x240 millimeters)
    > resolution: 102x108 dots per inch
    > depths (4): 1, 8, 12, 24
    > root window id: 0x34
    > depth of root window: 24 planes
    > number of colormaps: minimum 8183, maximum 8183
    > default colormap: 0x20
    > default number of colormap cells: 256
    > preallocated pixels: black 0, white 16777215
    > options: backing-store WHEN MAPPED, save-unders NO
    > largest cursor: 32x32
    > current input event mask: 0x780000
    > SubstructureNotifyMask SubstructureRedirectMask FocusChangeMask
    >
    > PropertyChangeMask
    > number of visuals: 3
    > default visual id: 0x23
    > visual:
    > visual id: 0x21
    > class: PseudoColor
    > depth: 8 planes
    > available colormap entries: 256
    > red, green, blue masks: 0x0, 0x0, 0x0
    > significant bits in color specification: 8 bits
    > visual:
    > visual id: 0x22
    > class: PseudoColor
    > depth: 12 planes
    > available colormap entries: 4096
    > red, green, blue masks: 0x0, 0x0, 0x0
    > significant bits in color specification: 8 bits
    > visual:
    > visual id: 0x23
    > class: TrueColor
    > depth: 24 planes
    > available colormap entries: 256 per subfield
    > red, green, blue masks: 0xff, 0xff00, 0xff0000
    > significant bits in color specification: 8 bits
    >
    > and I have no error. Since your problem seems platform-specific, please
    > post info on client and server.


    I had this problem using LessTIff, but not with Open Source Motif.

+ Reply to Thread