Subject: Re: xsrc/31163
To: None <macallan@netbsd.org, gnats-admin@netbsd.org,>
From: Martin Husemann <martin@duskware.de>
List: netbsd-bugs
Date: 09/06/2005 06:46:02
The following reply was made to PR xsrc/31163; it has been noted by GNATS.

From: Martin Husemann <martin@duskware.de>
To: macallan@NetBSD.org
Cc: NetBSD GNATS <gnats-bugs@netbsd.org>
Subject: Re: xsrc/31163
Date: Tue, 6 Sep 2005 08:45:56 +0200

 Nope, it's not that simple. True, the "depth" argument returned from
 setup_visual() is not passed to open_window() - but after changing that
 (and using the new arg in open_window) it still fails on first color
 allocation. There must be more to it...
 
 So there are two things:
 
  (1) the app is easily fixed by making the check for DefaultVisual()->class
      accept TrueColor as well as PseudoColor
 
  (2) if the server returns a visual array including a PseudoColor 8 bit
      depth visual, it should be usable - it's a server error, otherwise
      (and the failure is internal, isn't it?)
 
 Martin
 
 --- libcdcx.h.orig	1997-09-29 05:59:59.000000000 +0200
 +++ libcdcx.h	2005-09-06 08:42:32.000000000 +0200
 @@ -49,7 +49,7 @@ void draw_graph __P((struct xdpy *, Wind
  GC create_gc __P((struct xdpy *, Drawable, u_long, u_long));
  Display *open_display __P((char *, struct xdpy *));
  Window open_window __P((struct xdpy *, Window,  int, int, int, int, 
 -			u_long, u_long, u_long, Visual *));
 +			u_long, u_long, u_long, Visual *, int));
  void set_classhints __P((struct xdpy *, Window, char *, char *));
  void set_sizehints __P((struct xdpy *, Window, int, int, int, int));
  void set_stdhints __P((struct xdpy *, Window, char *, char *, 
 --- libcdcx.c.orig	2001-02-19 15:23:55.000000000 +0100
 +++ libcdcx.c	2005-09-06 08:42:32.000000000 +0200
 @@ -477,11 +477,11 @@ struct xdpy *xdpy;
   */
  
  Window open_window(xdpy, parent, x, y, w, h, bordercolor, backcolor,
 -		   event_mask, visual)
 +		   event_mask, visual, depth)
  
  struct xdpy *xdpy;
  Window parent;
 -int x, y, w, h;
 +int x, y, w, h, depth;
  u_long bordercolor, backcolor, event_mask;
  Visual *visual;
  
 @@ -498,7 +498,7 @@ Visual *visual;
  
    /* create */
    newwin = XCreateWindow(xdpy->dpy, parent, x, y, w, h, BORDER_WIDTH,
 -			 CopyFromParent, /* depth */
 +			 depth,
  			 InputOutput, /* class */
  			 visual, attrs_mask, &attrs);
  
 @@ -650,10 +650,11 @@ Visual **visual;
  int *depth;
  
  {
 -  int nvis;
 +  int nvis, defvis;
    XVisualInfo *visual_array, visual_info_template;
  
 -  if (DefaultVisual(xdpy->dpy, screen)->class == PseudoColor) {
 +  defvis = DefaultVisual(xdpy->dpy, screen)->class;
 +  if (defvis == PseudoColor || defvis == TrueColor) {
      *visual = DefaultVisual(xdpy->dpy, screen);
      *depth = DefaultDepth(xdpy->dpy, screen);
      return(True);
 --- xuvmstat.c.orig	2003-08-11 02:14:36.000000000 +0200
 +++ xuvmstat.c	2005-09-06 08:42:36.000000000 +0200
 @@ -76,7 +76,7 @@ char **argv;
    w = WIDTH;
    h = 650;
    win = open_window(&xdpy, xdpy.rootwin, x, y, w, h,
 -		    xdpy.black, xdpy.white, ExposureMask, visual);
 +		    xdpy.black, xdpy.white, ExposureMask, visual, depth);
  
    set_stdhints(&xdpy, win, argv[0], argv[0], x, y, w, h);