Re: [gtk-list] Re: Why is system visual == DefaultVisual?



Federico Mena Quintero wrote:
> 
> >  I've run into this on Suns when getting a drawing area widget and end
> >  up with an 8 bit visual and want a 24 bit visual.
> >
> >  Is the following ok (as long as I do it before the widget is realized)?
> >
> >  GdkVisual *vis_24 = gdk_visual_get_best_with_depth(24);
> >  if (vis_24) {
> >      gtk_widget_set_visual(GTK_WIDGET(widget_), vis_24);
> >  }
> 
> In general you don't want to do this, since it won't work for machines
> without 24-bit visuals.
> 
> What you usually care about is just a "thin" visual for most of your
> app and a "fat" visual for the widgets that require high image
> quality.  Assuming you will be painting to these widgets with
> something like GdkRGB, it is better to do
> 
>         /* Make sure GdkRGB is initialized */
>         gdk_rgb_init ();
> 
>         /* Switch to a fat visual */
>         gtk_widget_push_visual (gdk_rgb_get_visual ()):
>         gtk_widget_push_colormap (gdk_rgb_get_cmap ());
> 
>         da = gtk_drawing_area_new ();
> 
>         /* Go back to the default visual */
>         gtk_widget_pop_colormap ();
>         gtk_widget_pop_visual ();


I may be wrong here, but I don't think that always works on displays that
can only have one colormap installed at a time.

If the display only supports one colormap, I think you have to do the
push_visual()/push_colormap() before creating the entire window, since
the window manager will only switch to the toplevel windows' colormaps.

I used to use code like the above in Glade, when using GtkPreview widgets,
and I got a few BadMatch bug reports.

Damon




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]