[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1661.0. "PseudoColor Widget on FireFox?" by DUGGAN::WEAVER (Laboratory Data Products/Science) Thu Nov 02 1989 14:41

I am trying to create a widget that will let me use a PseudoColor visual type
on a Firefox.  I basically copied my XCreateWindow code that I had working
in an X-only application.  The problem I have is that I am getting a BadMatch
(see below).  I have created the colormaps and obtained the visual types with
no problems, and the code works on a PMAX which is defaulting to PseudoColor.
I have gone so far as to allocating named colors from my color table and
setting every *Pixel attribute in the window, and making sure all *Pixmap
attributes are set to None.  I even created my own cursor and allocated
the colors out of my local colormap.  I still get the BadMatch.  The parent
window was obtained by using XtWindow (w->core.parent), this may be the problem
as the ResourceID in failed request seems to be pointing to this.

Can anyone help?

						Thanks,
						-Dave


Visual: 1235236, class: 3, depth: 8, bits/rgb: 8
Creating 8 plane color map in 24 plane subsystem
Display: 12d1ec, Parent: 400014, x: 20, y: 15, w: 118, h: 208
Border w: 1, depth: 8, visual: 12d924, mask: 684f
X error event received from server: BadMatch - parameter mismatch
  Failed request major op code 1 X_CreateWindow
  Failed request minor op code 0 (if applicable)
  ResourceID 0x400014 in failed request (if applicable)
  Serial number of failed request 81
  Current serial number in output stream 90
Error event received from server
Symbolic stack dump follows
module name     routine name                     line       rel PC    abs PC

                                                           0005557F  0005557F
                                                           000553C8  000553C8
                                                           0005693B  0005693B
                                                           00054C26  00054C26
                                                           0004D35B  0004D35B
                                                           0010FC81  0010FC81
                                                           0010F2CD  0010F2CD
                                                           0010F2B8  0010F2B8
VW              main                             7999      000000DA  00000ADA

The following is the code before and including my call to XtCreateWindow (in
my realize procedure):


    if (old_visual->class != PseudoColor)
      {
        w->core.colormap = XCreateColormap (display, XRootWindow (display, scre>
                    w->visual, AllocNone);
        if (XPlanesOfScreen (XScreenOfDisplay(display,screen)) == 24)
          {
            printf ("Creating 8 plane color map in 24 plane subsystem\n");
            XInstallColormap (display, w->core.colormap);
          }
      }
    else
        w->core.colormap = XDefaultColormap (display, screen);

    XLookupColor (display, w->core.colormap, "red",
                &exact_color, &border_color);
    s1 = XAllocColor (display, w->core.colormap, &border_color);
    XLookupColor (display, w->core.colormap, "green",
                &exact_color, &back_color);
    s2 = XAllocColor (display, w->core.colormap, &back_color);

/* I verified that the XAllocColors work */

    if(s1)
      {
        attributesP->border_pixel = border_color.pixel;
        w->core.border_pixel = attributesP->border_pixel;
        *maskP |= CWBorderPixel;
      }
    if(s2)
      {
        attributesP->background_pixel = back_color.pixel;
        w->core.background_pixel = attributesP->background_pixel;
        *maskP |= CWBackPixel;
      }

/* bunch of cursor stuff left out */

    attributesP->cursor = w->cross_cursor;
    *maskP |= CWCursor;

    attributesP->colormap = w->core.colormap;
    attributesP->border_pixmap = None;
    attributesP->background_pixmap = None;
    attributesP->backing_store = NotUseful;
    attributesP->backing_pixel = back_color.pixel;
    attributesP->event_mask = 0;

    *maskP |= CWBorderPixmap | CWBackPixmap | CWColormap |
         CWBackingStore, CWBackingPixel;
/*
 * Create Window
 */

    printf ("Display: %x, Parent: %x, x: %d, y: %d, w: %d, h: %d\n",
                display, pwin, w->core.x, w->core.y, w->core.width,
                w->core.height);
    printf ("Border w: %d, depth: %d, visual: %x, mask: %x\n",
            w->core.border_width, 8, w->visual, *maskP);

    w->core.window = XCreateWindow (display, pwin, w->core.x, w->core.y,
        w->core.width, w->core.height, w->core.border_width, 8,
        InputOutput, w->visual, *maskP, attributesP);
T.RTitleUserPersonal
Name
DateLines
1661.1Try DW_EXAMPLESDECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Thu Nov 02 1989 22:197
    I can't see the problem offhand, but it is getting late.  Try looking
    at the color wheel program in DW_EXAMPLES.  It does it.  I suspect
    you are missing some window attribute which is defaulting to a
    24-plane version from its parent, but I can't see what it might be.
    
    Burns
    
1661.2DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Fri Nov 03 1989 09:469
I just checked CMAP.C.  I don't see anything missing in your window attributes.
The only thing I can think of is that w->visual is not really an 8-plane visual.
How did you get it?  You should probably do an XMatchVisual or XGetVisualInfo
to get it.  Then use the info returned by these to specify both the
visual and the depth rather than hard-coding the depth.  (You won't always
find that a pseudo-color visual is 8 deep, though that is probably true
on the FF).

Burns
1661.3DUGGAN::WEAVERLaboratory Data Products/ScienceFri Nov 03 1989 10:5341
Thanks for taking a peek.  I do use XGetVIsualInfo to obtain the visual.  The
following is the code:

I am confident this is doing the right thing, because it works as standalone
code (code not contained in a widget).  I think the problem may be with my
obtaining the parent widgets window ID.  Do you see anything wrong with my
assignment to "pwin"?

    display =    XtDisplay(w);
    pwin =       XtWindow(w->core.parent);
    screen =     XDefaultScreen (display);
    old_visual = XDefaultVisual (display, screen);

    p_fore = XWhitePixel (display, screen);
    p_back = XtBackground (w->core.parent);
    p_cmap = XDefaultColormap (display, screen);

    w->visual_info.depth = 8;
    w->visual_info.bits_per_rgb = 8;
    w->visual_info.class = PseudoColor;
    new_vis = XGetVisualInfo (display, (VisualDepthMask | VisualClassMask),
                    &(w->visual_info), &visuals_matched);
    w->visual = new_vis[0].visual;
    printf (" Obtained %d visuals\n",visuals_matched);
    for (index=0; index < visuals_matched; index++)
        printf ("Visual: %d, class: %d, depth: %d, bits/rgb: %d\n",
                new_vis[index].visual, new_vis[index].class,
                new_vis[index].depth, new_vis[index].bits_per_rgb);

    if (old_visual->class != PseudoColor)
      {
        w->core.colormap = XCreateColormap (display, XRootWindow (display, scre>
                    w->visual, AllocNone);
        if (XPlanesOfScreen (XScreenOfDisplay(display,screen)) == 24)
          {
            printf ("Creating 8 plane color map in 24 plane subsystem\n");
            XInstallColormap (display, w->core.colormap);
          }
      }
    else
        w->core.colormap = p_cmap;
1661.4DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Sat Nov 04 1989 12:246
Offline discussion has not yet resolved this.  He says that he has already
tried doing this with pure Xlib and it works fine, implying that the
issue is with the parent that he gets from the toolkit.  If anyone
has any ideas, I am sure they would be appreciated.  I am fresh out.

Burns
1661.5StumpedOXNARD::HAYNESCharles HaynesSun Nov 05 1989 14:5017
Got me, I can't figure it out.

Small nit.

	pwin =       XtWindow(w->core.parent);

should be

	pwin =       XtWindow(XtParent(w));

but that shouldn't affect correctness.

The widgets have been realized I assume?

This could be <gasp> a bug.

	-- Charles
1661.6DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Mon Nov 06 1989 12:315
I suppose you might try looking at the window id returned by the XtParent or
whatever to see if it is sensible.  (But if not, that should give you a
Window error, not a Match error...)

Burns
1661.7NOBOZO::WEBERFri Nov 10 1989 18:306
    I don't think the toolkit creates windows with anything but the default
    visual (at least this was the case several months ago when last I
    looked at it). Maybe a toolkit person can confirm this.
    
    /John
    
1661.8OXNARD::HAYNESCharles HaynesSat Nov 11 1989 16:4011
Re: .-1

He's creating his own window in the realize proc. The toolkit shouldn't care.

Re: .0

Have you run synchronous with a breakpoint in the Xlib error routine to see
exactly which window creation is failing? I realize this is farfetched, but
maybe it isn't *your* window which is failing?

	-- Charles